OPUS/UI

Navigation

Switch

Toggle with a springy thumb, three sizes and optional on/off glyphs inside the thumb.

4 files · 232 locdeps: clsx, tailwind-merge

Wi-Fi and Bluetooth stay on.

Installation

With the shadcn CLI, pointing at this platform’s registry:

npx shadcn@latest add https://opusui.131199999.xyz/r/switch.json

Or offline, straight from your opus55 checkout (copies every file it needs):

node ../tailwind_component/opus55/scripts/add.mjs switch

Usage

import { Switch } from "@/components/opus/ui/switch";

<Switch checked={on} onCheckedChange={setOn} />

API

PropTypeDefaultDescription
checked / defaultCheckedboolean—Controlled / uncontrolled state.
onCheckedChange(checked: boolean) => void—Change handler.
size"sm" | "md" | "lg""md"Track size.
thumbOn / thumbOffReactNode—Tiny glyph inside the thumb per state.

Command palette