Button
Presses spring back, the label lifts away for a spinner while pending, and an arrow nudges on hover.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/buttonThis adds components/keyframery/button.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { Button } from "@/components/keyframery/button"
export default function Usage() {
return <Button>Save changes</Button>
}Examples
Variants
Default for most actions, primary for the one that matters most, ghost for quiet ones and destructive for what can't be undone.
Sizes
sm for dense rows and toolbars, md by default, lg for a page's main action.
With an icon
Wrap a leading icon in ButtonIcon so it moves with the label. ButtonArrow draws a trailing arrow that nudges forward on hover.
Icon only
The icon sizes make a square button. Give it an aria-label, since there is no text to read.
Loading
Return a promise from onClick and the button shows a spinner until it settles. Screen readers hear pendingAnnouncement.
Disabled
Pass focusableWhenDisabled to keep it in the tab order, so a tooltip can say why.
Speed
speed changes how fast it moves. Click each one and watch the label make way for the spinner.
Motion
| Move | What you see |
|---|---|
| Press | The button sinks to 96% and springs back on release. |
| Direction | While pending, the label lifts away and a spinner rises in from below. |
| Draw | A trailing arrow nudges forward and draws its stem on hover. |
Timing and springiness follow the motion style you set. To change how fast this button moves, pass speed:
<Button speed="fast">
…
</Button>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--button-face | Variant key surface and hover mix | --background (dark --accent), --primary; ghost transparent |
--button-ink | Variant label and icons | --foreground / --primary-foreground / --destructive |
--button-radius | Corners by size | 8px / 9px / 10px |
--button-height | Height and icon width by size | 1.75rem / 2rem / 2.25rem |
--button-font | Label size by size | 12px / 13px / 14px |
API reference
Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK button reference.
Button
Renders a <button>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
ButtonArrowButtonIcon: a<span>
Keyboard
| Key | What it does |
|---|---|
| Enter | Presses the button. |
| Space | Presses the button. |
Accessibility
Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.
Swap the import
Already using UI SDK's button with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.
// Before
import { … } from "@ui-sdk/react/button"
// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/button"Questions
How does the animated Button for UI SDK move?
Press: The button sinks to 96% and springs back on release. Direction: While pending, the label lifts away and a spinner rises in from below. Draw: A trailing arrow nudges forward and draws its stem on hover.
Do I need Motion or Framer Motion for the animated Button?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
Can I keep my own styling and only take the motion?
Yes. Import from @/components/keyframery/primitives/button instead. It has the same parts and props as @ui-sdk/react/button and adds motion only.
What happens to the Button when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.
More in Actions
All componentsAll components
Every animated component for Vercel's UI SDK in one place: dialogs, menus, tabs, forms, charts and more. One shadcn command each; UI SDK's props stay the same.
Button Group
Buttons join into one strip, and a single highlight glides from segment to segment under the pointer or keyboard focus, taking each segment's corners as it goes.