Cart Button - React Component | Kokonut UI
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. Add it with the shadcn CLI, which copies the source into components/kokonutui/cart-button.tsx, so the code is yours to change.
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.
npm install lucide-react motion
Usage
import CartButton from "@/components/kokonutui/cart-button";
export default function Example() {
return <CartButton />;
}
Props
itemsCartItem[]
Defaultbuilt-indefaultQuantitiesRecord<string, number>
Default{ croissant: 2 }
Starting quantities, by item id.currencystring
Default"$"onCheckout(quantities: Record<string, number>) => voidclassNamestring
Extra classes for the root element.
CartItem
idrequiredstringnamerequiredstringdetailrequiredstring
Pack size or weight, shown under the name.pricerequirednumbericonrequiredLucideIcontintrequiredstring
Tailwind classes for the icon tile.maxnumber
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.