---
title: "Animated Close Icon"
description: "A cross for Close and Dismiss buttons. It wiggles once when you hover or focus the button."
url: https://gelatinui.com/components/animated-close-icon
markdown_url: https://gelatinui.com/components/animated-close-icon.md
access: free
install: "npx shadcn@latest add @gelatin-ui/animated-close-icon"
registry_item: https://gelatinui.com/r/animated-close-icon.json
version: "2026-11-15"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Animated Close Icon

> A cross for Close and Dismiss buttons. It wiggles once when you hover or focus the button.

Page: https://gelatinui.com/components/animated-close-icon

## When to use it

Best for: The cross of a Close or Dismiss icon button that answers a hover or a keyboard focus.

- Use it in a Close or Dismiss button: the hover or keyboard focus of the button plays it once.
- Give the button an `aria-label` such as "Close" when the icon is the only content.
- Set `trigger="none"` and raise `play` when the app should play it, not the hover.

## When not to use it

- For a cross that does not move, use the static `XIcon` in a [Button](https://gelatinui.com/components/button.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.
- Put it in an icon Button and name the button with `aria-label`: the icon is drawing only.
- A tap on a touch screen does not play it; a hover or a keyboard focus of the button does.

## Anatomy

```text
AnimatedCloseIcon
```

## API reference

### AnimatedCloseIcon

| 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. |
| `trigger` | `"hover" \| "none"` |  | `hover` (default) plays once per hover or keyboard focus of the control around the icon. |
| `play` | `number` |  | Plays once each time this number changes (a new notice, a saved form). |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| AnimatedCloseIcon | `animated-close-icon` |  |  |  |

## Usage

Put it in an icon Button. The hover or keyboard focus of the button plays it once; a tap on a touch screen does not.

The sample also uses `button`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/animated-close-icon @gelatin-ui/button
```

```tsx title="close-button.tsx"
import { AnimatedCloseIcon } from "@/components/icons/animated-close-icon";
import { Button } from "@/components/ui/button";

export function CloseButton({ onClose }: { onClose: () => void }) {
  return (
    <Button variant="ghost" size="icon" aria-label="Close" onClick={onClose}>
      <AnimatedCloseIcon />
    </Button>
  );
}
```

## 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/animated-close-icon
```

It adds 14 registry items: 13 files, 2445 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `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

- [Button](https://gelatinui.com/components/button.md)
- [Animated Copy Icon](https://gelatinui.com/components/animated-copy-icon.md)
- [Animated Chevron Icon](https://gelatinui.com/components/animated-chevron-icon.md)

## Accessibility

The icon is drawing only. Name the button that holds it (`aria-label`, or a visible label next to it).

It plays on a keyboard focus too, so keyboard users see the same response as pointer users.

## Motion

| Part | Motion |
| --- | --- |
| Wiggle | iconHover · 600ms · rotate −8° → 6° → −3° → 0 · once per hover or focus |
