# Cart Button

An Add button that opens into a quantity stepper in place, with a bin at one and press-and-hold to repeat.

Install with `npx shadcn@latest add https://kokonutui.com/r/cart-button.json`, then show me how to use it.

- **Oat milk** $3.20 · 1 L · Barista
  
  Add

- **Butter croissant** $2.60 · Baked this morning
  
  Quantity of Butter croissant 2 Butter croissant in cart 2

- **Cherries** $5.80 · 500 g punnet
  
  Add

**Subtotal** · 2 items  
$5.20  
Checkout

## Installation

Cart Button is a free, open-source React component in the Kokonut UI [Buttons collection](/content/docs/buttons/index.html). Add it with the shadcn CLI, which copies the source into `components/kokonutui/cart-button.tsx`, so the code is yours to change.

```bash
npx shadcn@latest add @kokonutui/cart-button
```

Or add it by hand: install its packages, then copy the source from above into `components/kokonutui/cart-button.tsx`.

```bash
npm install lucide-react motion
```

## Usage

```javascript
import CartButton from "@/components/kokonutui/cart-button";

export default function Example() {
  return <CartButton />;
}
```

## Props

- `items`  
  `CartItem[]`  
  Default `built-in`

- `defaultQuantities`  
  `Record<string, number>`  
  Default `{ croissant: 2 }`  
  Starting quantities, by item id.

- `currency`  
  `string`  
  Default `"$"`
  
- `onCheckout`  
  `(quantities: Record<string, number>) => void`

- `className`  
  `string`  
  Extra classes for the root element.

### CartItem

- `id` required  
  `string`

- `name` required  
  `string`

- `detail` required  
  `string`  
  Pack size or weight, shown under the name.

- `price` required  
  `number`

- `icon` required  
  `LucideIcon`

- `tint` required  
  `string`  
  Tailwind classes for the icon tile.

- `max`  
  `number`

## Dependencies

| Needs | Version | Comes from |
| --- | --- | --- |
| `lucide-react` | `^0.556.0` | npm, installed by the CLI |
| `motion` | `^12.23.25` | npm, installed by the CLI |
| `cn` from `lib/utils.ts` |  | shadcn init |
| React | `19` | Your app |
| Tailwind CSS | `4` | Your app |

No provider, font or global CSS to set up: the file works as soon as it lands.
