---
title: "Animated Sun Moon Icon"
description: "One icon for a light and dark mode button. The sun bends into a moon, and a small star twinkles."
url: https://gelatinui.com/components/animated-sun-moon-icon
markdown_url: https://gelatinui.com/components/animated-sun-moon-icon.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/animated-sun-moon-icon"
version: "2026-11-13"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Animated Sun Moon Icon

> One icon for a light and dark mode button. The sun bends into a moon, and a small star twinkles.

Page: https://gelatinui.com/components/animated-sun-moon-icon

## When to use it

Best for: One button that switches between light and dark mode.

- Set `dark` from the resolved theme.
- Put it in an icon Button with `aria-pressed`.

## When not to use it

- For a choice of light, dark, and system, use a [Toggle Group](https://gelatinui.com/components/toggle-group.md).

## Notes for agents

- `variant` (`stroke`, `solid`, `duotone`, `twotone`, `bulk`) and `corners` (`round`, `sharp`) pick the style. Use one style for every icon of a product.
- `dark` is the only prop of its own. The default is `false`.
- A change mid-move turns back from where the points are.
- The icon is `aria-hidden`. The control around it owns the name.

## Anatomy

```text
AnimatedSunMoonIcon
```

## API reference

### AnimatedSunMoonIcon

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"bulk" \| "duotone" \| "solid" \| "stroke" \| "twotone"` |  | `stroke` (default): 1.5 strokes. `solid`: the body filled, inner details cut through. `duotone`: a 40% fill under the stroke. `twotone`: the details at 40%. `bulk`: the body filled at 40% with no outline, the details at full color. |
| `corners` | `"round" \| "sharp"` |  | `round` (default): round caps and joins, soft corners. `sharp`: square caps, miter joins. |
| `dark` | `boolean` | false | Dark: shows the moon. Light: shows the sun. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| AnimatedSunMoonIcon | `animated-sun-moon-icon` |  |  |  |

## Usage

Import Animated Sun Moon Icon and compose its parts.

```tsx title="animated-sun-moon-icon.tsx"
import { AnimatedSunMoonIcon } from "@/components/pro/icons/animated-sun-moon-icon";

export function AnimatedSunMoonIconDemo() {
  return <AnimatedSunMoonIcon className="size-12" />;
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/animated-sun-moon-icon
```

It adds 9 registry items: 8 files, 2039 lines, and the npm packages `@base-ui/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Animated Undo Icon](https://gelatinui.com/components/animated-undo-icon.md)
- [Animated Trash Icon](https://gelatinui.com/components/animated-trash-icon.md)

## Accessibility

The icon is hidden from assistive tools. The control around it owns the name.
