Search documentation

Search components and pages

Toggle

A two-state button that can be either on or off.

01

Installation

Add the toggle component with the shadcn CLI.

bash
npx shadcn@latest add https://swiss.ui.unsanity.ai/r/toggle.json
02

Usage

tsx
import { Toggle } from "@/components/ui/toggle"
03

Examples

Default

import { BoldIcon } from "lucide-react"

import { Toggle } from "@/components/ui/toggle"

<Toggle aria-label="Toggle bold">
  <BoldIcon />
</Toggle>