106k
New

Toggle

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

import { Toggle } from "@/components/ui/toggle"
import { BookmarkIcon } from "lucide-react"

Installation

pnpm dlx shadcn@latest add toggle

Usage

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

Examples

Outline

Use variant="outline" for an outline style.

import { Toggle } from "@/components/ui/toggle"
import { BoldIcon, ItalicIcon } from "lucide-react"

With Text

import { Toggle } from "@/components/ui/toggle"
import { ItalicIcon } from "lucide-react"

Size

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

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

export function ToggleSizes() {

Disabled

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

export function ToggleDisabled() {

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

"use client"

import * as React from "react"

API Reference

See the Base UI Toggle documentation.