---
title: Toggle Switch
description: A toggle switch that can be used to turn on or off a feature.
labels: ["requires interaction", "toggle"]
author: Aadarsh Baral
---

<ComponentPreview name="button-toggle-switch--docs" />

## Installation

<Steps>

<Step>Update `tailwind.config.js`</Step>
```js
theme: {
    extend: {
     colors: {
        foreground: "hsl(var(--foreground))",
     }
    },
  },
```

<Step>Run the following command</Step>

It will create a new file called `toggle-switch.tsx` inside the `components/animata/button` directory.

```bash
mkdir -p components/animata/button && touch components/animata/button/toggle-switch.tsx
```

<Step>Paste the code</Step>

Open the newly created file and paste the following code:

```jsx file=<rootDir>/animata/button/toggle-switch.tsx

```

</Steps>

## Credits

Built by [Aadarsh Baral](https://github.com/aadarshbaral)
