Examples
Default
Disabled
Sizes
Icon slots
showLeftIcon and showRightIcon are independent booleans, each rendering the add glyph on that side. Both are available on the default variant only — the ai variant types them as never, since its sparkle is fixed and it has no trailing slot.
Matrix
Mirrors theV2 Toggle Figma frame: every size against every state, for both variants. The hover column is painted with the hover token directly, since a real :hover cannot be held open in a static snapshot — move the pointer over the inactive column to see the genuine transition.
Props
SwitchButton
A labelled pill that switches one feature or mode on and off, for settings panels, filter bars and tool options. UnlikeSwitch it names the thing it controls, which suits contexts where the action needs spelling out.
Rendered as a <button> carrying aria-pressed — the ARIA toggle-button pattern — so it flips on click and on Enter or Space, and exposes data-state="on" | "off" for styling. Supports controlled (pressed) and uncontrolled (defaultPressed) usage. The visible label is the accessible name, so no aria-label is needed.
For two or three mutually exclusive options, reach for SegmentedControl instead: this button is independently on or off, not a choice between options.
Icon rendered before the label when
showLeftIcon is set. Unavailable on "ai" — the leading sparkle is fixed.Icon rendered after the label when
showRightIcon is set. Unavailable on "ai" — this variant has no trailing icon slot.Show an icon before the label. Unavailable on
"ai" — the leading sparkle is always shown and cannot be swapped.Show an icon after the label. Unavailable on
"ai" — this variant has no trailing icon slot.Exported types
Also exported from@fanvue/ui: SwitchButtonAiProps, SwitchButtonDefaultProps, SwitchButtonProps, SwitchButtonSize, SwitchButtonVariant.
Setup: Installation · Theming