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

Research ToggleButtons #957

Open
lukewarlow opened this issue Nov 18, 2023 · 9 comments
Open

Research ToggleButtons #957

lukewarlow opened this issue Nov 18, 2023 · 9 comments
Labels
needs-research This issue needs research in order to move forward stale

Comments

@lukewarlow
Copy link
Collaborator

lukewarlow commented Nov 18, 2023

Toggle buttons are pretty common UI elements that currently require aria (aria-pressed). I feel these would be relatively simple to specify a native ability for.

First thing to do would be pull together research on existing design systems to work out existing implementations. (https://react-spectrum.adobe.com/react-aria/ToggleButton.html is just one example)

@lukewarlow lukewarlow added the needs-research This issue needs research in order to move forward label Nov 18, 2023
@lukewarlow
Copy link
Collaborator Author

lukewarlow commented Nov 18, 2023

Name tbd obviously (would probably go with <button type="toggle"> or <button type="button" toggle>).

But then maybe we want a pressed attribute to take the true false mixed values.

Which begs the question do we want tri-state?

How do we handle styling is there an existing pseudo class that works (:active?) Or do we need a new one (`:pressed)?

All of this would hopefully be answered by research.

@lukewarlow
Copy link
Collaborator Author

I propose this would be a valid element for invoketarget (like a button with type="button" and type="reset")

@lukewarlow
Copy link
Collaborator Author

lukewarlow commented Nov 18, 2023

These along with focusgroup would allow for a proper toolbar implementation such as the one on the GitHub comments panel (or really any Toolbar). We are however currently missing a toolbar semantic element, potentially we could spec one of those too which could provide the focusgroup semantics without needing to ship focusgroup itself as a pre-requesite.

Also useful for UI such as in video calls where you have UI for toggling microphone and camera state (though it's key that we educate to ensure people don't change the label as part of changing the pressed state).

@scottaohara
Copy link
Collaborator

@lukewarlow i had been tooling around with a draft proposal for this a couple weeks ago. I would argue that instead of introducing a new attribute, we reuse the checked attribute.

unfortunately 'toggle' (in this context indicating a pressed/not pressed or mixed state) could get confusing with 'toggling' a popover/dialog - since those are also toggling but not self toggling. sigh. we need more words rather than calling everyting a tooltip, toggle or a card.

@lukewarlow
Copy link
Collaborator Author

Yeah thinking on it I think pressed (to match aria?) or checked or something other than toggle is for the best.

@bkardell
Copy link
Collaborator

I agree either of those is better than toggle or toggled or whatever.

@keithamus
Copy link
Collaborator

Allowing a list of options inside of a button, and having the button cycle between those might be worthwhile:

<button type=toggle>
  <option value="play">Play</option>
  <option value="pause">Pause</option>
</button>

Providing <options> allows for a computed value, an easily computed accname, a well understood transition of state, and it is webcompat (to my knowledge).

We are looking at adding richer media to <option> for <select> so it would be a net gain here too.

Having option also allows for N states, which may either sell you on the idea or put you off it entirely 😉 :

<button type=toggle>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three<option>
</button>

@lukewarlow
Copy link
Collaborator Author

I've raised some issues to try and gather some use cases.

#1039 - toggle buttons
#1040 - cycle buttons (the sort of thing Keith mentions above)

Copy link

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.

@github-actions github-actions bot added the stale label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-research This issue needs research in order to move forward stale
Projects
None yet
Development

No branches or pull requests

4 participants