Toggle

<Toggle>TailwindCSS Modules

A two-state button that can be toggled on or off, often grouped together for single or multiple selection.

InstallationColoxo CLI
npx coloxo add toggle --style coloxo-css
ES Module ImportPlayground / npm package
import { Toggle, ToggleGroup, ToggleGroupItem } from '@coloxo/ui';

Design Tokens:

--cx-brand-50: #EEF2FF--cx-brand-600: #2348FF--cx-slate-100: #F1F5F9--cx-radius-md: 8px

1. Variant Matrix

Toggles can be used standalone or in groups for radio-like or checkbox-like behavior.

Standalone ToggleGroup (Single Select)Group (Multiple Select)
States

2. Interactive Props Configurator

Selection Mode

Disabled State

Visual Render Canvas
tsx
<ToggleGroup  type="single"  aria-label="Text styling">  <ToggleGroupItem value="bold" icon={<Bold />} aria-label="Bold" />  <ToggleGroupItem value="italic" icon={<Italic />} aria-label="Italic" />  <ToggleGroupItem value="underline" icon={<Underline />} aria-label="Underline" /></ToggleGroup>

3. Dark theme

Toggles invert gracefully, using subtle highlight colors for pressed states.

4. Enterprise layout compositions

Toggles are perfect for toolbars, formatting options, and quick view switchers.

Editor Toolbar

Accessibility

Aria Pressed

Standalone Toggles use `aria-pressed` to indicate state. ToggleGroups use radiogroup semantics (for single select) or independent toggle buttons (for multiple select).

Icon Labels

When using icon-only Toggles, always provide an `aria-label` so screen readers can identify the button's purpose.

Props

NameTypeDefaultDescription
pressedboolean—Controlled pressed state (Toggle).
defaultPressedboolean—Uncontrolled initial pressed state.
onPressedChange(pressed: boolean) => void—Pressed change handler.
size"sm" | "md" | "lg"mdControl size.
variant"default" | "outline"defaultVisual style for standalone Toggle.
iconReactNode—Optional leading icon.
ToggleGroup.type"single" | "multiple"singleSelection mode.
ToggleGroup.valuestring | string[]—Controlled value(s).
ToggleGroupItem.valuestring—Item value within the group.