---
title: "Toggle switch animated icon"
description: "Toggle switch animated icon (Forms & input). Knob pulls back, snaps across the track, and settles; toggle returns it."
canonical: https://generativeicons.lottiefiles.com/icons/toggle-switch/
---

# Toggle switch animated icon

Knob pulls back, snaps across the track, and settles; toggle returns it.

- Id: `toggle-switch`
- Category: Forms & input
- Search terms: on off, enable, disable, enabled, disabled, turn on, turn off, activate, deactivate, flip switch
- Two states: off to on, played forward and back
- Styles: outline, solid, duotone; outline weights 1.5, 2, 2.5 (any from 1 to 3); motion light or strong
- File: https://generativeicons.lottiefiles.com/assets/toggle-switch.lottie (dotLottie, 6365 bytes, sha256 30a672f3a401174b34863a58beeeba07b5a71a3713268184564eaa3683199c93)
- License: MIT

## Install

```sh
npm install @lottiefiles/generative-icons-runtime
npx generative-icons init
npx generative-icons add toggle-switch
```

## React

```tsx
// npm install @lottiefiles/generative-icons-react
'use client';
import { AnimatedIcon } from '@lottiefiles/generative-icons-react';
import icon, { src } from './generative-icons/toggle-switch.mjs';

export function ToggleSwitchIcon() {
  return <AnimatedIcon icon={icon} src={src} size={32}
    color="#ffffff" variant="outline" weight={2}
    motion="light" theme="dark" />;
}
```

## JavaScript

```js
import { createIcon } from '@lottiefiles/generative-icons-runtime';
import icon, { src } from './generative-icons/toggle-switch.mjs';

const handle = await createIcon(canvas, {
  icon, src,
  color: '#ffffff', style: 'outline', weight: 2,
  motion: 'light', theme: 'dark'
});
button.addEventListener('click', () => handle.play());
// On removal: handle.destroy();
```

More: https://generativeicons.lottiefiles.com/icons/toggle-switch/ · https://generativeicons.lottiefiles.com/api/icons/toggle-switch
