Skip to content
Buttons

Toggle

Server Component

A two-state on/off button.

Import

tsx
import { Toggle } from "@cronus-ui/ui";
bash
npx cronus-ui add toggle

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 2/2Pixel diff 0 pxLogic 1/1Parity scoreboard
off.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component ToggleOff layout:inline style:toggle {
  label "Bold"
}

page "/audit/toggle/off" type:custom {
  use ToggleOff
}
on.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component ToggleOn layout:inline style:toggle {
  pressed:true
  label "Bold"
}

page "/audit/toggle/on" type:custom {
  use ToggleOn
}

API Reference

Generated from the component's exported types.

ToggleProps

Extends ComponentPropsWithoutRef<typeof TogglePrimitive.Root>, VariantProps<typeof toggleVariants>

Skip ToggleProps props table
PropTypeDefaultDescription
variant
"default" | "outline""default"One of "default" | "outline".
size
"sm" | "md" | "lg""md"One of "sm" | "md" | "lg".
pressed
boolean—Controlled pressed state.
defaultPressed
boolean—Uncontrolled initial pressed state.
onPressedChange
(pressed: boolean) => void——
disabled
boolean—Disables pointer and keyboard interaction.
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.