Switch

A tactile toggle for settings that take effect immediately.

npx shadcn@latest add @silicon-ui/switch
togglesettings
Loading…

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. Shared files are skipped if you already have them.

    • components/silicon-ui/switch/switch.tsx
    • components/silicon-ui/switch/switch.module.css
  3. Install the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

Source codetsx
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