Skip to content

Switch

A tactile toggle for settings that take effect immediately.

ToggleSettings
npx shadcn@latest add @silicon-ui/switch

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/switch

Manually

  1. Install the dependencies

    npm install @radix-ui/react-switch motion
  2. Copy these files into your project

    • components/silicon-ui/switch/switch.tsx
    • components/silicon-ui/switch/switch.module.css
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { Switch } from "@/components/silicon-ui/switch/switch";

API reference

PropTypeDefault
labelstring—

Also accepts the props of ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>.

Dependencies

npm
@radix-ui/react-switchmotion
Registry
silicon-motion-tokens