Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Toggle for React

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

Installation

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

Usage

import { BookmarkIcon } from "lucide-react";
import { Toggle } from "@/components/ui/toggle";
<Toggle aria-label="Toggle bookmark" size="sm" variant="outline">
  <BookmarkIcon
    aria-hidden="true"
    className="group-aria-pressed/toggle:fill-foreground"
  />
  Bookmark
</Toggle>

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.

Demos

Outline

Use variant="outline" for an outline style.

Text

Toggle with an icon and text label.

Sizes

Use the size prop to change the size of the toggle.

Disabled

Disabled toggles in default and outline variants.

Rtl

Right-to-left toggle. See the RTL configuration guide for document direction.

API Reference

Toggle

PropType
AttributeType

ToggleIndicator

PropType
AttributeType