Add to Cart
Smart add-to-cart button with built-in
validation, loading states, and error handling that automatically works with Product context.Interactive Demo
Try the add-to-cart button in different configurations using the variant switcher:
Loading playground...
Component Props
onClick(cartDetail: CartDetail) => voidCallback function that receives the cart detail object when item is successfully added
onError(error: Error) => voidCallback function for handling validation or cart errors
textstringButton text in default state (default: "Add to Cart")
loadingTextstringButton text during cart operation (default: "Adding...")
successTextstringButton text after successful addition (default: "Added!")
quantitynumberNumber of items to add (default: 1)
simulateDelaynumberSimulated cart operation delay in milliseconds (default: 1000)
classNamestringCSS classes to apply to the button element
Installation
npx merchify-cli init
This CLI will guide you through setting up Merchify components in your project