Skip to content

Toggle button

Switches a button between selected and unselected states.

toggle-button-demo.tsx

Installation

The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.

Independent toggles

Notify me by
toggle-button-independent-demo.tsx

Sizes

Set iconOnly for a square toggle, and give it an aria-label.

toggle-button-sizes-demo.tsx

API reference

vip/ui adds or changes the props below. For all other props, see React Aria ToggleButton (opens in a new tab).

variant: "default" | "segmented" | "ghost" = "default"
Sets the surface. Use segmented inside a ToggleButtonGroup. All variants show the selected state.
size: "xs" | "sm" | "md" | "lg" | "xl" = "md"
Uses the Button heights. Without a size, a segmented toggle is 44 pixels high on small screens and 36 pixels from 640 pixels.
iconOnly: boolean = false
Makes the toggle a square for one icon. Give the toggle an aria-label.