Keyframery

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.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/button

This 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

MoveWhat you see
PressThe button sinks to 96% and springs back on release.
DirectionWhile pending, the label lifts away and a spinner rises in from below.
DrawA 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.

VariableWhat it changesDefault
--button-faceVariant key surface and hover mix--background (dark --accent), --primary; ghost transparent
--button-inkVariant label and icons--foreground / --primary-foreground / --destructive
--button-radiusCorners by size8px / 9px / 10px
--button-heightHeight and icon width by size1.75rem / 2rem / 2.25rem
--button-fontLabel size by size12px / 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:

  • ButtonArrow
  • ButtonIcon: a <span>

Keyboard

KeyWhat it does
EnterPresses the button.
SpacePresses 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.

All components

On this page