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.
string
required
Visible text label, which is also the accessible name.
boolean
default:"false"
Initial on/off state for uncontrolled usage.
ReactNode
default:"<AddIcon size={16} />"
Icon rendered before the label when
showLeftIcon is set. Unavailable on "ai" — the leading sparkle is fixed.((pressed: boolean) => void)
Fired with the next state each time the button flips.
boolean
On/off state for controlled usage. Pair with
onPressedChange.ReactNode
default:"<AddIcon size={16} />"
Icon rendered after the label when
showRightIcon is set. Unavailable on "ai" — this variant has no trailing icon slot.boolean
default:"false"
Show an icon before the label. Unavailable on
"ai" — the leading sparkle is always shown and cannot be swapped.boolean
default:"false"
Show an icon after the label. Unavailable on
"ai" — this variant has no trailing icon slot."24" | "32" | "40"
default:"32"
Height of the button in pixels.
"button" | "submit" | "reset"
default:"button"
Native button behaviour.
"default" | "ai"
default:"default"
Visual treatment.
Exported types
Also exported from@fanvue/ui: SwitchButtonAiProps, SwitchButtonDefaultProps, SwitchButtonProps, SwitchButtonSize, SwitchButtonVariant.
Setup: Installation · Theming