Toggle
Two-state button (pressed / unpressed). Mirrors shadcn Toggle. Built on @radix-ui/react-toggle.
Purpose
Two-state button (pressed / unpressed). Mirrors shadcn Toggle. Built on @radix-ui/react-toggle.
Island model
island: true when controlled. Uncontrolled (defaultPressed) usage with no state observation can render as a static <button aria-pressed> with no JS — the build decides.
Peer dependencies
@radix-ui/react-toggle@^1.1class-variance-authority@^0.7
Public API
export type ToggleVariant = "default" | "outline"
export type ToggleSize = "default" | "sm" | "lg"
export function Toggle(props: Radix.ToggleProps & { variant?: ToggleVariant; size?: ToggleSize; className?: string }): JSX.Element
export const toggleVariants: (opts: { variant?: ToggleVariant; size?: ToggleSize }) => string
export const island = true
Patties adjustments
- Removes
forwardRef. toggleVariantsexported for use by 58-toggle-group.
Acceptance criteria
- Clicking flips
data-stateandaria-pressed. - Keyboard
SpaceandEntertoggle. - Variants and sizes snapshot correctly.