---
title: Toggle
description: A two-state button that can be either on or off.
component: true
radix:
  link: https://www.radix-ui.com/docs/primitives/components/toggle
  api: https://www.radix-ui.com/docs/primitives/components/toggle#api-reference
---

<ComponentExample src="/components/examples/toggle/demo.tsx">
  <ToggleDemo />
</ComponentExample>

## Installation

```bash
npx shadcn-ui add toggle
```

<Accordion type="single" collapsible>
  <AccordionItem value="manual-installation">
    <AccordionTrigger>Manual Installation</AccordionTrigger>
    <AccordionContent>

1. Install the `@radix-ui/react-toggle` component from radix-ui:

```bash
npm install @radix-ui/react-toggle
```

2. Copy and paste the following code into your project.

<ComponentSource src="/components/ui/toggle.tsx" />

<Callout>
  This is the `<Toggle />` primitive. You can place it in a file at
  `components/ui/toggle.tsx`.
</Callout>

    </AccordionContent>

  </AccordionItem>
</Accordion>

## Usage

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

```tsx
<Toggle>Toggle</Toggle>
```

## Examples

### Default

<ComponentExample src="/components/examples/toggle/demo.tsx">
  <ToggleDemo />
</ComponentExample>

---

### Outline

<ComponentExample src="/components/examples/toggle/outline.tsx">
  <ToggleOutline />
</ComponentExample>

---

### With Text

<ComponentExample src="/components/examples/toggle/with-text.tsx">
  <ToggleWithText />
</ComponentExample>

---

### Small

<ComponentExample src="/components/examples/toggle/sm.tsx">
  <ToggleSm />
</ComponentExample>

---

### Large

<ComponentExample src="/components/examples/toggle/lg.tsx">
  <ToggleLg />
</ComponentExample>

---

### Disabled

<ComponentExample src="/components/examples/toggle/disabled.tsx">
  <ToggleDisabled />
</ComponentExample>
