---
title: "Dark mode animated icon"
description: "Dark mode animated icon (Preferences). Light: the rays draw into the sun and the disc morphs into a crescent moon. Strong: the rays snap in, the disc grows into the moon with a stop and swings 50° into place. Reverse: the moon morphs back and the rays grow out."
canonical: https://generativeicons.com/icons/dark-mode/
---

# Dark mode animated icon

Light: the rays draw into the sun and the disc morphs into a crescent moon. Strong: the rays snap in, the disc grows into the moon with a stop and swings 50° into place. Reverse: the moon morphs back and the rays grow out.

- Id: `dark-mode`
- Category: Preferences
- Search terms: night mode, light mode, dark theme, night theme, theme toggle, switch theme, day and night, day night, sun moon, lights out
- Two states: day to night, 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.com/assets/dark-mode.lottie (dotLottie, 25960 bytes, sha256 0e9b0401ed1fb11462c28dc5da0e9afbda46ce5ab884d8d67f3afbf897e0a73f)
- License: MIT

## Install

```sh
npm install @lottiefiles/generative-icons-runtime
npx generative-icons init
npx generative-icons add dark-mode
```

## React

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

export function DarkModeIcon() {
  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/dark-mode.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.com/icons/dark-mode/ · https://generativeicons.com/api/icons/dark-mode
