---
title: Toggle Button
description: A two-state button that can be either on or off.
link:
  doc: https://kobalte.dev/docs/core/components/toggle-button
  api: https://kobalte.dev/docs/core/components/toggle-button#api-reference
---

<ComponentPreview name="toggle-button-demo">

```tsx file=<rootDir>/apps/docs/src/registry/examples/toggle-button-demo.tsx

```

</ComponentPreview>

## Installation

<ComponentInstallation>

<Step>

<StepItem>Copy and paste the following code into your project:</StepItem>

  <ComponentSourceTabs>

    ```tsx title="components/ui/toggle-button" file=<rootDir>/apps/docs/src/registry/ui/toggle-button.tsx

    ```

    ```tsx title="components/ui/toggle-button" file=<rootDir>/apps/unocss-playground/src/registry/ui/toggle-button.tsx

    ```

  </ComponentSourceTabs>

</Step>

</ComponentInstallation>

## Usage

```tsx
import { ToggleButton } from "@/components/ui/toggle-button"
```

```tsx
<ToggleButton />
```

## Examples

### Outline

<ComponentPreview name="toggle-button-outline-demo">

```tsx file=<rootDir>/apps/docs/src/registry/examples/toggle-button-outline-demo.tsx

```

</ComponentPreview>

### Size

<ComponentPreview name="toggle-button-size-demo">

```tsx file=<rootDir>/apps/docs/src/registry/examples/toggle-button-size-demo.tsx

```

</ComponentPreview>

### Disabled

<ComponentPreview name="toggle-button-disabled-demo">

```tsx file=<rootDir>/apps/docs/src/registry/examples/toggle-button-disabled-demo.tsx

```

</ComponentPreview>
