Skip to main content

AddToCartButton

Adds products to Shop's cart with checkmark animation feedback. Users can continue shopping and add more items before checkout. Use this for browsing experiences where customers might want multiple products. For immediate single-product purchases, use BuyNowButton instead.

Anchor to className
className
string

CSS class name

Anchor to disabled
disabled
boolean

Whether the button is disabled

Anchor to discountCodes
discountCodes
string[]

The discount codes to apply to the cart

Anchor to product
product

The product to add to the cart

Anchor to productVariantId
productVariantId
string

The GID of the product variant. E.g. gid://shopify/ProductVariant/456. Optional — when omitted, the button opens the native variant selector sheet so the user can pick a variant before adding to cart. Requires product to be set so the button has a productId to act on.

'default' | 'sm' | 'lg'

Button size variant

Examples
import * as React from 'react'
import {AddToCartButton, useProduct} from '@shopify/shop-minis-react'

export default function MyComponent() {
const {product, loading} = useProduct({
id: 'gid://shopify/Product/7234590834753',
})

if (loading || !product) {
return null
}

return (
<AddToCartButton
product={product}
productVariantId={product.defaultVariantId}
/>
)
}

Preview

addtocartbutton

Was this page helpful?