-
Notifications
You must be signed in to change notification settings - Fork 83
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
Toggle switch #893
Comments
Sounds alright – thanks for the example! This has been on the “bucket list” from the beginning, with the name of “toggle-button” (corresponding to I’ll probably want to go through the visual design before actually merging, though ;) I’m also wondering about accessibility – is there something extra that we should do for keyboard users, like support arrow keys for toggling it? And does anyone care about dragging the toggle or is tapping always enough? Though, these are aspects that we can be solved later – we can start with smaller increments. |
So this shouldn't be a
Of course, mine was just a fiddle not a proper PR 😃 Before issuing a PR I wished to know:
In my example it's just CSS so you can still focus it with TAB and toggle it with SPACE or ENTER.
Good question! Never tried to "drag" a switch element, sincerely. What do you have in mind? Something like a "dimmer", to set a fractional value? |
Here’s my take on the visual design: The sizing is so that the width is What do you think, should we adjust the label position to be before the toggle/switch? And if the user sets the width of the host the toggle/switch would always be at the end (making the label part flex)? I think that’s perhaps a more common layout for a toggle/switch, rather than having the label follow the What about two-line label? Should we align the toggle/swith on the baseline of the first line, or center it with the whole label? See the same question for radio-button: vaadin/vaadin-radio-button#61 (comment) |
I've updated the fiddle with your design: https://jsfiddle.net/heruan/g0tx9f29/ But again, that's just a theme for the plain I'm attempting to answer my questions in the previous comment:
|
Nitpick: the off state bg color should be contrast-40pct (not 30pct). Also, Material Design calls these “switches” nowadays. That’s why I propose we use that as well, and not “toggle button”. |
@jouni in fact... PolymerElements/paper-toggle-button#71 About the dragging, the |
If we rely on the checkbox state, then somehow the checkbox itself should change state on swiping (with particular attention to the swipe direction, too); no idea how to do this, though 😄
Gone!
Which color should I use? I tried |
The swiping is something we can add in a later version – no need to worry about that in the first version. Let’s see if we/users really even need it :) I was implying we could leave the small shadow for the circle, but remove it when it’s disabled. That’s how it is in the latest mockup I added. The colors I used for the background:
|
I've rewritten the fiddle starting from the Lumo checkbox (not the unstyled one), so that it can be simply included as a custom theme and applied to Plus, it inherits Lumo common styles and effects from the original checkbox like hovering and glowing when activating. I've also added a Here's the updated fiddle: https://jsfiddle.net/heruan/g0tx9f29/4 |
Are there any plans for a |
@Juchar thanks for the suggestion. That's something worth considering. One concern is that I'm not sure how well does it fit Material guidelines. There is a Toggle button concept but it seems to be more like a radio group (only one option can be selected at a time). |
See https://github.com/vaadin/vaadin-button/issues/86 for button groups. |
@jouni This seems to be related to just create a group of buttons, but would not fulfill the use case of a "toggle" button group where one can switch true/false states, right? |
@Juchar, I think that’s up for discussion/design if buttons should have a toggle state as well. I’m mostly concerned about trying to make checkboxes look like buttons. To get rid of the normal checkbox styles (so that we don’t need to override them) I think we’d need to extend Not sure if that’s the easier approach or would it be easier to add a toggle state for |
@jouni I completely understand what you mean. As you said, that's an architectural design decision that vaadin would have to make. Not sure what would be better tough. |
Article about toggle button groups and a11y, probably also relevant here: https://lea.verou.me/2022/07/button-group/ |
Note that a theme variant (of Checkbox) is insufficient for this since switches needs a different ARIA role for WCAG conformance: |
What about including a toggle switch theme for
vaadin-checkbox
?This is for example a CSS-only theme:
Fiddle: https://jsfiddle.net/heruan/g0tx9f29/
The text was updated successfully, but these errors were encountered: