-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IconButton: Recommended approach to showing toggle state #9941
Comments
@phallguy I believe the relevant section in the specification is the following: https://material.io/guidelines/components/buttons.html#buttons-toggle-buttons. The 'on' state should simply be a matter of setting a However, it seems that we don't follow the specification closely enough. The focus indicator ring should take the color of the icon into account. Right now, we don't. |
Ahh thanks for pointing me in the right direction. Didn't even think to check the buttons page - had 'toggle' on the brain! This will work for me. Thanks! |
Having another look at it - the look I'm going after would be the "toggle buttons" shown in a group where it looks pressed. |
I'm happy to submit a PR if this is a behavior the material team would like to include in the library. |
@phallguy We have had a primary effort in this direction with #7551. Unfortunately, it was never finished nor polished. Yes, it would be awesome to have it! Thanks for proposing your help. I would encourage you to:
|
Great, I think I can pull something simple together. Really love the work you guys are doing and would love to be able to give a bit back. |
@phallguy I have closed the issue. The |
Haven't gotten started on it yet, was going to spend some time on it today. I'm thinking as first step adding some sort of 'active' prop to ButtonBase so that each of the various buttons can be used in a toggle state and ensuring that the IconButton uses the current color for the focus ring. Then was going to start on the menu style toggle buttons. The Supported Comments doc calls them Toggle buttons (same as material UI) so I was going to go for ToggleButton and if needed ToggleButtonGroup. But happy to use ButtonToggle if you'd prefer. I'll open a new issue for each of these and we can formalize requirements in those. |
@oliviertassinari fixed that today: #9967 ToggleButton sounds more natural to me. (IconButton, ToggleButton...) |
@phallguy
|
Filed initial PR #10144 |
I'm working on a tool that allows certain states to be toggled from a toolbar (think bold/italic/etc). I'd like to show that certain states are enabled. I know the switch component makes this every easy but I'd like to mimic existing toolbar like functionality found in most WYSIWYGs.
What is the recommend approach for showing toggle state with an IconButton?
This may be outside the material spec but I would suspect something others would like do in their apps as they become more rich and rely more heavily on material-ui for all of the UX.
Expected Behavior
I'd like some sort of 'on' or 'pressed' prop that results in corresponding visual representation on the IconButton.
Current Behavior
No props available. Which I think is by design but hopefully the use case is persuasive to reconsider.
Context
I hope to use this metaphor in a WYSIWYG editor as well as a few other toolbars within the app. I think a toggle state on a button more closely aligns to user's expectation of how a format toolbar should work than some sort of switch control.
Your Environment
The text was updated successfully, but these errors were encountered: