Switch
Shadcn switch reconstructed on Proto UI.
Ordinary demos on this page explicitly use Shadcn Rhea, with matching examples. This does not change public compatibility defaults or imply complete browser, native-host or visual acceptance. Neutral Surface/Text atoms retain their own public semantics; the consumer composition supplies the family presentation theme.
This entry shows the current shadcn switch implementation in Proto UI.
Set size="sm" on the Root for the small recipe; omit size or use size="default" for the default recipe. The Thumb derives size from its actual logical Switch Root and has no size prop. Changing size does not change the checked value or emit checkedChange.
The selected Rhea recipe uses a 2rem × 1.25rem default Root, a 1.5rem × 1rem small Root, 1rem/0.75rem Thumbs, a 2px transparent border and family radius-2xl; checked travel is Thumb width minus 4px. See the Rhea style source. The separate 02cad611 New York source retains its 2rem × 1.15rem / 1.5rem × 0.875rem dimensions and minus-2px travel as the compatibility profile. These are distinct profiles, not a claim of cross-target rendered parity.
Compositions and optional drag
Section titled “Compositions and optional drag”Default Switch compositions remain click/Space controls. Drag is an explicit enhancement (draggable: true), not a change to upstream defaults. In the size example above only “Email alerts” opts in; the two dedicated examples below make LTR and RTL drag visible separately.
The following public composition uses the existing Field label, description and Switch owners. Choice Cards make the blank card area clickable without creating another button or forwarding a click; the nested “Learn more” link retains its own action. Selected paint follows the accepted checked value, including when a controlled owner rejects a request. Disabled and read-only examples must not request a change.
The upstream Choice Card anatomy wraps Field inside FieldLabel. Proto keeps its existing Field anatomy and separate accessible description rather than importing that framework or changing the current style profile. This composition is not a Liquid Glass Switch implementation.
Install
Section titled “Install”
npx @proto.ui/cli@latest add wc shadcn-switch
Replace wc with react, vue or vue2 to generate the facade for that host.
Passing checked selects controlled mode.
| Prop | Type | Default |
|---|---|---|
checked | boolean undefined | uncontrolled |
defaultChecked | boolean | false |
disabled | boolean | false |
draggable | boolean | false |
direction | 'ltr' 'rtl' | ltr |
size | 'default' 'sm' | default |
size is the Shadcn presentation prop. Thumb has no props. Root remains the only checked-value owner.