Docs menu

Switch

A switch whose thumb is a tiny mochi. Flip it and the mochi smears across the track, slams into the far end with a splash and wakes up with a !. Flip it back and it dozes off with a little Zzz. The colour floods out from under it.

Installation

❯ npx shadcn@latest add https://yan.moe/r/switch.json

Usage

tsx
import { Switch } from "@/components/ui/switch"
tsx
<Switch defaultChecked aria-label="Sparkles" />

Accessibility

  • Built on Radix Switch: it renders a <button role="switch"> and toggles with Space or Enter.
  • Wrap it in a <label> or pass aria-label; the mochi face is decorative and hidden from assistive tech.
  • With prefers-reduced-motion: reduce, the smear, splash and emote are skipped.

API

PropTypeDefault
intensity

kawaii: smear, slam, splash and an emote. subtle: a small stretch and sparkles. off: plain.

"kawaii" | "subtle" | "off""kawaii"
fx

Overrides for the splash fired when the thumb lands.

BurstOptions-
checked / defaultChecked

Controlled and uncontrolled state, as in Radix.

boolean-
onCheckedChange

Called when the state changes.

(checked: boolean) => void-