Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Toggle for React and Tailwind

Two-state button that can be toggled on or off.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/toggle.json

Usage

import { 
  Toggle,   
  ToggleIndicator 
} from "@/components/ui/toggle"; 
<Toggle>
  <ToggleIndicator />
</Toggle>

Controlled

Use the pressed and onPressedChange props to control the toggle state programmatically.

States

Disabled

Use the disabled prop to disable the toggle.

Variants

Default

Outline

Sizes

Small

Medium

Large

Examples

Icon Group

Use multiple toggles with icons for toolbar-style controls.

API Reference

Toggle

Toggle button for on/off or selected state. Use asChild for custom elements.

PropTypeDefault
variant"outline" | "ghost""ghost"
size"sm" | "md" | "lg""md"
pressedboolean-
defaultPressedbooleanfalse
disabledbooleanfalse
onPressedChange(details: PressedChangeDetails) => void-
classNamestring-
asChildbooleanfalse

ToggleIndicator

Icon or indicator shown when toggle is active. Omitted when used as child.

PropTypeDefault
classNamestring-
asChildbooleanfalse

For a complete list of props, see the Ark UI documentation.