Hyunsui
Docs
Toggle
Accessible switch component that exposes data-state for styling, mirrors Radix Toggle's API, and forwards all native button props.
Anatomy
Compose Toggle.Root with a Toggle.Thumb (or any custom child) to build your switch UI.
API Reference
Root
Acts as a button with role="switch", manages controlled/uncontrolled state, and forwards all native button props (including type, event handlers, etc.).
PropTypeDefault
checked
boolean-
defaultChecked
booleanfalse
onCheckedChange
(checked: boolean) => void-
disabled
booleanfalse
Data AttributeValue
data-state
"on" | "off"
data-disabled
""
Thumb
Stateless visual indicator that consumes context from Toggle.Root and mirrors data-state/data-disabled for styling.
PropTypeDefault
children
HTMLAttributes<HTMLSpanElement>-
Data AttributeValue
data-state
"on" | "off"
data-disabled
""