Toggle

Sharp rectangular track + sliding rectangular thumb. Same vocabulary as Checkbox, but feels like a hardware switch.

States

Add to your project

One command adds this component to your project.

1

Run the following command. New project? Run npx shadcn@latest init first to set up Tailwind and path aliases.

npx shadcn@latest add @aicanvas/andromeda-toggle

Props

Every prop this component accepts. Any other prop is forwarded to the underlying element.

PropTypeDefaultDescription
checkedboolean-Controlled checked state; supplying it puts the switch in controlled mode.
defaultCheckedbooleanfalseInitial checked state when uncontrolled.
onCheckedChange(next: boolean) => void-Handler called with the next checked state whenever the switch toggles.
labelstring-Optional text rendered beside the switch and linked to it via htmlFor.
disabledbooleanfalseDisables interaction and dims the switch.
classNamestring-Extra classes merged onto the visual track.
styleReact.CSSProperties-Inline styles merged onto the wrapper element.
idstring-Id for the input; falls back to a generated id and links the label.

More Andromeda components