Add to Cart

A cart button that morphs into a quantity stepper with a rolling count.

Preview

"use client";

import { AddToCart } from "@/components/motion/add-to-cart";

export function AddToCartUsage() {
  return <AddToCart />;
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/add-to-cart

API Reference

quantity?
number

Items in the cart, for controlled use. 0 shows the add button.

Default—
defaultQuantity?
number

The initial quantity when uncontrolled. Default: 0

Default0
onQuantityChange?
((quantity: number) => void)

Called with the new quantity when an item is added or removed.

Default—
max?
number

Most items one cart line can hold.

Default99
disabled?
boolean

Blocks adding and stepping, and dims the button. Default: false

Defaultfalse
labels?
Partial<{ add: string; increase: string; decrease: string; remove: string; quantity: string; }>

Override any built-in string, e.g. for translation.

Default—
sound?
boolean

Play a drop on add, a tick per step and a crumple on remove. Off by default; a `SoundProvider` can mute it app-wide.

Defaultfalse
morphWidth?
boolean

Resize the pill to fit each face (default). Turn it off and give it a width, for example `w-full`, to keep one size in both states.

Defaulttrue
className?
string

Classes merged onto the root element.

Default—

Updated