Toggle
A two-state button that can be either on or off.
Installation
pnpm dlx cubix@latest add toggle --base radixUsage
import { Toggle } from "@/components/cubix/toggle"<Toggle>Toggle</Toggle>Outline
Use variant="outline" for an outline style.
With Text
Size
Use the size prop to change the size of the toggle.
Disabled
RTL
Wrap the toggle in a container with dir="rtl" to mirror direction.
API Reference
See also the Base UI Toggle documentation for primitive props.
Toggle
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "outline" | "default" | Visual style of the toggle. |
| size | "default" | "sm" | "lg" | "default" | Size of the toggle. |
| pressed | boolean | - | Controlled pressed state. |
| defaultPressed | boolean | - | Uncontrolled initial pressed state. |
| onPressedChange | (pressed: boolean) => void | - | Called when the pressed state changes. |
| disabled | boolean | false | When true, interaction is disabled. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |