Toggle
A Shadcn toggle projected from the Base toggle protocol.
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 toggle implementation in Proto UI.
The selected Rhea recipe maps to the pinned Rhea style source: default/sm/lg heights are 2rem/1.75rem/2.25rem (16px root font), min-width matches height, inline padding is 0.625rem on every size, gap is 0.25rem and the radius is rounded-2xl (upstream contract --radius ×1.8; Proto currently approximates it as --pui-radius +8px — the two agree only at the pinned 0.625rem/10px base, so no dynamic-base parity is claimed); outline keeps border-input with no shadow; pressed uses a muted surface; hover uses the foreground ink plus a muted surface that the shared base recipe hover:bg-muted defines for both variants at the same pinned revision — .cn-toggle-variant-outline merely repeats it, so the default-variant hover surface is source-defined, not a Proto addition. The separate 02cad611 New York source retains its 36/32/40px heights, accent active paint, outline shadow-xs and muted-foreground default hover as the compatibility profile. These are distinct profiles, not a claim of cross-target rendered parity.
Toggle active, disabled, keyboard and a11y remain Base-owned. asChild is intentionally unavailable; native-prop and pressed-API aliases, invalid handling and arbitrary nested-SVG styling remain compatibility differences. This page and source tests are not four-runtime, two-theme native pixel acceptance.
The demo is Bold, pressed Italic outline, small Underline, disabled pressed Strikethrough, large text, and an outline toggle. Names for the icon toggles are visually hidden.
Install
Section titled “Install”
npx @proto.ui/cli@latest add wc shadcn-toggle
Replace wc with react, vue or vue2 to generate the facade for that host.
Passing active selects controlled mode.
| Prop | Type | Default |
|---|---|---|
active | boolean undefined | uncontrolled |
defaultActive | boolean | false |
disabled | boolean | false |
variant | 'default' 'outline' | default |
size | 'default' 'sm' 'lg' | default |
Root exposes active, disabled, hovered, focused, focusVisible, and pressed, plus activeChange.