openui / open-ui

Maintain an open standard for UI and promote its adherence and adoption.
https://open-ui.org
Other
3.59k stars 191 forks source link

Use cases for a button with a pressed state #1039

Open lukewarlow opened 7 months ago

lukewarlow commented 7 months ago

This issue is for collecting use cases for a button with a pressed state. Sometimes referred to as toggle buttons (but that's an overloaded term), or aria-pressed buttons (but that's an implementation detail).

I'm not looking for ideas on how this could be implemented (e.g. checkbox, switch, select), just for examples of how it would be used.

The usecase shouldn't need more than 2 states (for now lets ignore the aria-pressed mixed case unless you've a strong example)

lukewarlow commented 7 months ago

If you want something like a "toggle" button but want more states, see https://github.com/openui/open-ui/issues/1040

o-t-w commented 7 months ago

The use case example I see most often is bold/italic/underline.

Screenshot 2024-04-24 at 11 29 36

A pretty common pattern is that a button, after being pressed, can be unpressed, but pressing another button will also automatically unpress it, so only zero or one options can be pressed at a time. Styling the background of a Trello board is one of many examples of this.

Screenshot 2024-04-24 at 18 31 16

Would a submit button be allowed to be a toggle button? A lot of the time all you might want visually in the <form> is that one button and perhaps some hidden inputs.

lukewarlow commented 7 months ago

YouTube music has this sort of button for it's mute icon button. The iconogrophy changes but the label is just "Mute"

image image

julien-deramond commented 7 months ago

We have some toggle buttons in Bootstrap documentation (visually identical but technically slightly different for a11y reasons), but without any real-world example use cases:

In some Orange websites (using a fork of Bootstrap for their web framework), it is frequent to see these toggle buttons used for filtering purpose as the Goldman Sachs example shared in https://github.com/openui/open-ui/issues/1039#issuecomment-2074548503.

scottaohara commented 7 months ago

rich text editors often use toggle buttons (pressed/not pressed states)

see TinyMCE's demo. Collapsed toolbar shows bold / italic which are toggles. Additional controls in the expanded toolbar are also toggles

gfellerph commented 7 months ago

Maybe the trigger button for a popover as in Google Docs which is pressed as long as the popover is open.

image
scottaohara commented 7 months ago

That wouldn’t be appropriate for a pressed/not pressed state. That would be an expanded/collapsed. That’s what popovertarget would expose, for instance

yisibl commented 6 months ago

What is the difference between this and the <switch> element?

yisibl commented 6 months ago

There are many such buttons in iOS or other mobile systems.

image

scottaohara commented 6 months ago

Similar in functionality (toggle between states) but different semantics / manner in which they are exposed to assistive technology

github-actions[bot] commented 3 days ago

There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label.