Motion UIComponentsComponent

Add to basket

A product image that arcs into the basket icon, with a recoil and ripple on arrival.

npx shadcn@latest add @motion/add-to-basket

API reference

Components

<AddToBasketImage />

Wraps product artwork that flies into the basket.

children?

ReactNode

Product artwork that flies into the basket.

className?

string

Merged onto the wrapping element.

ref?

Ref<AddToBasketImageHandle>

Imperative handle driving the flight.

<AddToBasketTarget />

Wraps the basket so it can take the hit and ripple on impact.

children?

ReactNode

Basket icon or any landing element.

className?

string

Merged onto the wrapping element.

ref?

Ref<AddToBasketTargetHandle>

Imperative handle driving the recoil.

<AddToBasketButton />

Styled trigger with theme snap hover/tap feel.

children?

ReactNode = "Add to basket"

The button's visible label.

className?

string

Merged onto the button element.

disabled?

boolean

Disable while an add is in flight.

onClick?

() => void

Click handler, typically calls addToBasket.

Functions

addToBasket

Runs the full fly-to-basket choreography. Resolves true at the landing beat.

addToBasket(options: AddToBasketOptions): Promise<boolean>

image

AddToBasketImageHandle | null

The AddToBasketImage handle.

basket

AddToBasketTargetHandle | null

The AddToBasketTarget handle.

direction?

ArcDirection = "cw"

Which way the flight arc bends.

Related examples