Switch

Radix switch with a sketch pill track and a circular thumb that slides. Toggling springs the thumb and re-inks the track with a second seed.

<Switch label="Keep the wobble" defaultChecked roughness={1.5} />

CLI install

npx doodleui-react add switch

Usage

import { Switch } from "doodleui-react";

<Switch label="Keep the wobble" defaultChecked />

Checked state, keyboard, and aria-checked come from Radix. doodle-ui draws the track and thumb.

Props

PropTypeDefaultNotes
labelReactNodeundefinedCaption sitting to the right of the track.
checked / onCheckedChangeboolean / (checked: boolean) => voiduncontrolledRadix controlled API.
animatebooleantrueThumb slides with a spring. Track seed-morphs on toggle. Overrides DoodleUIProvider. Reduced motion disables this unless the provider set forceAnimate.
roughnessnumber1.5How wobbly the stroke is. 0 is almost geometric. 3+ is messy.
seednumberprovider / randomLocks the sketch. Omit to follow SketchSeedProvider (Shuffle) or a mount-time random seed.
sketchColorstring#1f1d1aStroke color. Also tints primary/accent fills where relevant.
classNamestringundefinedPassed through to the root element.
styleCSSPropertiesundefinedPassed through to the root element.