A button that carries its confirmation: a ball swallows the label and flies on an arc to a counter elsewhere on the page, which rolls by one.
Click meTap me
Restock order
Low stock · Juniper Goods
3301234567893 products in the restock order
S
Stoneware mug, sand
SKU 2041 · 4 left
C
Canvas tote, olive
SKU 1187 · 2 left
D
Desk lamp, chalk
SKU 0932 · 6 left
L
Linen napkins, rust
SKU 0415 · Out of stock
carry-button · , lively
carry-button-demo.tsx
When to use
Use it when an action puts something into a collection that is shown elsewhere on the page, so the flight shows where the item went. Pair it with CarryCount as the target.
When not to use
For an action with no visible destination on the page use a plain button or Action Button.
Use Carry Button when an action puts something into a collection shown elsewhere on the page: add to a restock order, save to a reading list, attach to a cart in the header. Pressing gives birth to a ball under the finger, the pill closes into it and swallows the label, and the ball flies on an arc to a CarryCount, flattens against it and melts in while the count rolls by one. The journey tells the person where the item went. For an action with no destination on screen, use a regular button; for a pure count update with no gesture, use the counter alone.
import { useRef, useState } from "react"import { CarryButton, CarryCount } from "@/components/ui/carry-button"export function ProductRow() { const countRef = useRef<HTMLSpanElement>(null) const [count, setCount] = useState(0) return ( <div className="flex items-center justify-between gap-4"> <CarryCount ref={countRef} value={count} label="items in the order" reserveFor={99} /> <CarryButton target={countRef} onLand={() => setCount((n) => n + 1)}> Add to order </CarryButton> </div> )}
CarryButton flies to target, a ref to a CarryCount or to an element that holds one (a cart button in the header). Increment the count in onLand: it runs when the ball touches the target. CarryCount reserves the width of reserveFor, so the count never shifts the layout.
onCarry runs on click after onClick. When it returns a promise, the ball waits in the button as a loading state; resolved, it flies; rejected, it hops in place in destructive and the label returns.
Presets set the arc: toss (default, a clear arc across the page), lob (a high arc for a target close by) and skim (a flat arc for a target right above or beside the button). intensity multiplies the arc's height. variant takes the shadcn Button names (default, secondary, outline, ghost) and size is sm, md, lg or icon. token is what the ball carries (default "+1": two characters or a 12 px icon). asChild renders a single child, such as a link, with the button's behaviour and look.
Set the character for the whole app with MotionKitProvider, or per instance with temperament (calm, lively, playful). It changes motion intensity only, never the drawing.
The default demo: a shop back office where each low-stock product goes into the restock order with one click. The order count sits in the header above the buttons' column, and the first row adds itself once when the panel comes into view.
Saving takes a moment, so the ball waits in the button until the promise settles, then skims to the Saved tab. The private note rejects: the ball hops back in destructive and the error is announced.
CarryButton renders a native button (or, with asChild, your link with the same behaviour). Give icon-only buttons an aria-label.
While busy it sets aria-busy and aria-disabled; a click while busy is ignored and a link does not navigate.
The ball, the flying copy, the dashed frame and the skin are aria-hidden. The label is laid out once invisibly, so the button keeps its width whatever happens.
CarryCount is a polite live region: every change is announced as the value followed by label ("4 products in the restock order"), even off screen.
The button mounts its own polite live region when announce or onCarry is set: announce.carried is read on landing (leave it empty when a CarryCount already announces) and announce.error on a rejected onCarry ("Failed" by default).
The ball takes the customer's --primary when it has color, else --brand, at a fixed lightness per theme: white ink in light, near-black ink in dark, both at least 4.5:1 on the fill. A rejected carry uses destructive.
No sink, ball or flight: the label stays in place, the counter crossfades to the new value with a 2 px ring that fades out, and the change is announced. With a promise, the pill closes onto a still ball while it waits and reopens when it settles. onLand still runs, so the count is always updated.
Only transform, opacity and clip-path change. The flight runs in a fixed portal (MotionKitProvider's portal container, else document.body) and is removed when the ball has melted in.
The arc is planned once, from the geometry captured at the click: nothing is measured per frame.
At most three balls are in the air; more clicks count at once, without a ball. A target off screen is hit at the nearest viewport edge.
The loading breath is the only loop and runs only while busy, on screen and in a visible tab (useShouldAnimate). A flight that never reports its end (tab hidden mid-flight) lands on a safety timer.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-slot, motion.
Dependencies
@radix-ui/react-slot · peer
motion · peer
Triggers
click, press, a loading state, an app event
Reduced motion
No sink, ball or flight: the label stays, the counter crossfades to the new value with a 2 px ring that fades out, and the change is announced.
Keyboard
Tab
Moves focus to the button; it stays focused while the ball flies
Space / Enter
Charges while the key is down, then carries (the ball is born in the middle of the button)
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)