anthony lio
3b12d2e167
feat(ui): switch component ( #53379 )
...
## Problem
* the shared switch in `packages/ui` uses the radix primitive
* the thumb does not react to hover or press, and only the track color
shows the state
* a click on a switch label toggles the switch, but the label keeps the
default cursor
## Solution
* replaces the radix switch with base ui, and keeps a native `<button>`,
so labels and `role="switch"` work as before
* changes the thumb to white and the resting track one step darker, so
the off state shows on light pages
* replaces the hover color change with a thumb stretch that grows more
on press, so the thumb reacts to the pointer
* adds a pointer cursor on labels next to an enabled switch, because a
click on the label toggles it
* removes the `PointerEvent` stand-in from the studio test setup,
because it blocks base ui switch clicks in jsdom
* changes the install step in the switch docs to `@base-ui/react`, so
the manual install matches the component
<!-- linear:table-colwidths:345,344 -->
<table>
<thead>
<tr>
<th></th>
<th>preview</th>
</tr>
</thead>
<tbody>
<tr>
<td>light</td>
<td>
https://github.com/user-attachments/assets/a7c33dda-3487-43b8-881b-344e28891650
</td>
</tr>
<tr>
<td>dark</td>
<td>
https://github.com/user-attachments/assets/9718057b-f983-4099-8f7e-82521001b625
</td>
</tr>
</tbody>
</table>
## Preview links
| Site | Live | Preview | Search for |
| -- | -- | -- | -- |
| Design system |
[/design-system/docs/components/switch](<https://supabase.com/design-system/docs/components/switch >)
|
[/design-system/docs/components/switch](<https://design-system-git-feat-switch-base-ui-supabase.vercel.app/design-system/docs/components/switch >)
| Airplane Mode |
| Studio |
[/dashboard/project/\_/storage/files](<https://supabase.com/dashboard/project/_/storage/files >)
|
[/dashboard/project/\_/storage/files](<https://studio-git-feat-switch-base-ui-supabase.vercel.app/dashboard/project/_/storage/files >)
| Public bucket |
## Review instructions
1. open
[/design-system/docs/components/switch](<https://supabase.com/design-system/docs/components/switch >)
and
[/design-system/docs/components/switch](<https://design-system-git-feat-switch-base-ui-supabase.vercel.app/design-system/docs/components/switch >)
side by side
2. hover and click the "airplane mode" label, and make sure that the
cursor is a pointer and the switch toggles
3. change the theme to light and to dark, and make sure that the thumb
stays white in the on and off states
4. scroll to the form example, and make sure that the disabled "security
emails" switch does not toggle or stretch
5. open
[/dashboard/project/\_/storage/files](<https://studio-git-feat-switch-base-ui-supabase.vercel.app/dashboard/project/_/storage/files >),
click "new bucket" and turn on "public bucket", and make sure that the
"public buckets are not protected" warning shows
## Checklist
Check all before review:
- [X] I have read
[CONTRIBUTING.md](<https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md >)
- [X] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](<https://github.com/supabase/supabase/tree/master/apps/docs/style-guide >)
2026-11-19 21:32:09 +00:00