Skip to content
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

Use cases for a button with a pressed state #1039

Open
lukewarlow opened this issue Apr 22, 2024 · 10 comments
Open

Use cases for a button with a pressed state #1039

lukewarlow opened this issue Apr 22, 2024 · 10 comments
Labels
research This is for any issue that is related to open-ui research work

Comments

@lukewarlow
Copy link
Collaborator

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 lukewarlow added the research This is for any issue that is related to open-ui research work label Apr 22, 2024
@lukewarlow
Copy link
Collaborator Author

If you want something like a "toggle" button but want more states, see #1040

@o-t-w
Copy link

o-t-w commented Apr 24, 2024

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

  • Material Design uses bold/italic/underline as the examples (they also classify text-alignment as "toggle" but that's actually tabs not toggle as you can only select one at a time). They also have a favourite ❤️ button example.
  • Shadcn uses bold/unbold as the example
  • Fluent UI includes a toggle button but the docs site doesn't have any real-world example use cases
  • Salesforce have a follow/unfollow button example. Twitter is also another obvious example of that use case. Also bookmark/unbookmark button on Twitter.
  • Prime Vue uses a locked/unlocked example. Their docs site is using a toggle button to select between light/dark mode
  • This article from Inclusive Components uses a play/pause button as an example. That's also something Jeremy Keith talks about in an article of his referring to a play/pause button used on The Session website.
  • GitHub - subscribe/unsubscribe. Email subscription toggle is also used on the Medium website:
Screenshot 2024-04-24 at 11 29 36
  • Many examples of show/hide eyeball button for password fields and other sensitive fields
  • Goldman Sachs has a "toggle tag" example for filtering. This is relatively common. See also Google Fonts filter below:
Screenshot 2024-04-24 at 11 08 45
  • Google Meet/Zoom and other video conferencing apps: raise hand/lower hand toggle. webcam on/off. mute/unmute your microphone. Mute/unmute audio. captions on/off
Screenshot 2024-04-24 at 16 17 32
  • Trello: enable/disable colorblind mode
Screenshot 2024-04-24 at 18 26 01

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
Copy link
Collaborator Author

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
Copy link
Contributor

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 #1039 (comment).

@scottaohara
Copy link
Collaborator

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
Copy link
Contributor

gfellerph commented Apr 26, 2024

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

image

@scottaohara
Copy link
Collaborator

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
Copy link

yisibl commented May 24, 2024

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

@yisibl
Copy link

yisibl commented May 24, 2024

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

image

@scottaohara
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
research This is for any issue that is related to open-ui research work
Projects
None yet
Development

No branches or pull requests

6 participants