AddToBag

One pill that is the add button until pressed, then grows a stepper in place. Step back to zero and it folds up again. Buttons.

Open playground

About

AddToBag is a React component in the Buttons category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { AddToBag } from "@ashutoshswamy/smoui" and set label, value, defaultValue among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { AddToBag } from "@ashutoshswamy/smoui";

<AddToBag max={5} onChange={(qty) => setCart(qty)} />

Props 5

label

Idle label. Default Add to bag.

string
value

Controlled quantity.

number
defaultValue

Starting quantity when uncontrolled.

number
max

Highest quantity. Default 9.

number
onChange

Called whenever the quantity changes.

(quantity: number) => void