feat(api-reference): light/dark/system buttons variant (for supporting auto/system/device mode) #5636
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently, once you click a click light/dark mode toggle, you'll be stuck with that forever, unless you clear your localStorage. That goes for both
icon
andtoggle
variants.Solution
With this PR, there's an additional variant for the toggle, which is
buttons
.buttons
is a row-of-three div containing buttons, as light -> system -> dark.Storybook images
Video example:
Screen.Recording.2025-05-13.at.14.45.09.mov
The weird pauses is me Cmd+Spacing and going for "Toggle System Appearance", imitating the behaviour of a system going into light or dark mode respectively.
As there is no icon library, and the sun and moon icons are made by hand (which are really cool), I've opted for a simple, encompassed A. Alternatively, any phone icon, desktop icon, system icon, or even gear icon would work, but as the sun and moon are really, really thin, I've not found one that works, bar the A.
These automatically get stored in the localStorage, as per the
setColorMode
function available.It's also available in Storybook. I've not checked any other side-effects, such as the api-client, and I can't seem to get that to work locally.
I've gone and replaced the default api-reference from
ToggleButton
toToggleSelect
, although that wouldn't be necessary. Easy revert if needed.Checklist
I’ve gone through the following:
pnpm changeset
).