---
title: "Animated Cart Icon"
description: "A shopping cart for an Add to cart button. When the item is added, the plus turns into a check and the cart rolls. It rolls on hover too."
url: https://gelatinui.com/components/animated-cart-icon
markdown_url: https://gelatinui.com/components/animated-cart-icon.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/animated-cart-icon"
version: "2026-11-24"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Animated Cart Icon

> A shopping cart for an Add to cart button. When the item is added, the plus turns into a check and the cart rolls. It rolls on hover too.

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

## When to use it

Best for: An Add to cart toggle: the plus turns into a check when the item is added, and the cart rolls.

- Use it in an Add to cart button or in an icon button of a product row.
- Set `checked` from the in-cart state. Each change plays the roll.

## When not to use it

- For a Send a gift button, use the [Animated Gift Icon](https://gelatinui.com/components/animated-gift-icon.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.
- `checked` is the added state. The default is `false`. Nothing plays on mount.
- `trigger` is `hover` by default: the hover or the keyboard focus of the control plays one small roll.
- The icon is `aria-hidden`. Put `aria-pressed` and the name on the button, and change the label: Add to cart, Added to cart.

## Anatomy

```text
AnimatedCartIcon
```

## API reference

### AnimatedCartIcon

| 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). |
| `checked` | `boolean` | false | Added to the cart: the plus turns into a check. Each change rolls the cart. Default `false`. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| AnimatedCartIcon | `animated-cart-icon` |  |  |  |

## Usage

Set `checked` from the in-cart state, and put `aria-pressed` on the button.

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-pro/animated-cart-icon @gelatin-ui/button
```

```tsx title="add-to-cart-button.tsx"
import { useState } from "react";

import { AnimatedCartIcon } from "@/components/pro/icons/animated-cart-icon";
import { Button } from "@/components/ui/button";

export function AddToCartButton() {
  const [added, setAdded] = useState(false);
  return (
    <Button
      aria-pressed={added}
      onClick={() => {
        setAdded((current) => {
          return !current;
        });
      }}
    >
      <AnimatedCartIcon data-icon="inline-start" checked={added} />
      {added ? "Added to cart" : "Add to cart"}
    </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-pro/animated-cart-icon
```

It adds 14 registry items: 13 files, 2513 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)
- [Toggle](https://gelatinui.com/components/toggle.md)
- [Animated Gift Icon](https://gelatinui.com/components/animated-gift-icon.md)

## Accessibility

The icon is hidden from assistive tools. Put the name and `aria-pressed` on the button.

## Motion

| Part | Motion |
| --- | --- |
| Add | iconDraw · the plus fades out and the check draws in |
| Roll | iconHover · the cart rolls 1.5 units forward and back, and the wheels turn |
