Toggle

A two-state button that can be either on or off.

Installation

pnpm dlx cubix@latest add toggle --base radix

Usage

Import
import { Toggle } from "@/components/cubix/toggle"
Example
<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

PropTypeDefaultDescription
variant"default" | "outline""default"Visual style of the toggle.
size"default" | "sm" | "lg""default"Size of the toggle.
pressedboolean-Controlled pressed state.
defaultPressedboolean-Uncontrolled initial pressed state.
onPressedChange(pressed: boolean) => void-Called when the pressed state changes.
disabledbooleanfalseWhen true, interaction is disabled.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).