Keyframery

Checkbox

The box pops as it fills and the check draws itself.

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/checkbox

This adds components/keyframery/checkbox.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 { Checkbox } from "@/components/keyframery/checkbox"

export default function Usage() {
  return (
    <label className="flex items-center gap-2">
      <Checkbox />
      Accept the terms
    </label>
  )
}

Examples

Basic

Wrap it in a label so the text toggles it too.

Group with select all

In a CheckboxGroup with allValues, a checkbox marked parent checks them all. It shows a dash when only some are.

Controlled

Pass checked and onCheckedChange to keep it in your own state.

Motion

MoveWhat you see
PopThe filled box pops in.
DrawThe check draws itself just after; the mixed state draws a dash.
PressThe box shrinks slightly while pressed.

Timing and springiness follow the motion style you set. To change how fast this checkbox moves, pass speed:

<Checkbox speed="fast">
  …
</Checkbox>

"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
--checkbox-sizeCheckbox size18px
--checkbox-radiusBox corners5px
--checkbox-faceUnchecked box surface--background; dark --accent 40%
--checkbox-accentChecked box surface and hover mix--primary
--checkbox-inkCheck and dash--primary-foreground
--checkbox-gapGroup spacing0.625rem

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 checkbox reference.

Checkbox

Renders a <button>, and takes its props too.

Prop

Type

CheckboxGroup

Renders a <div>, and takes its props too.

Prop

Type

CheckboxIndicator

Renders a <span>, and takes its props too.

Prop

Type

Keyboard

KeyWhat it does
SpaceChecks or unchecks it.

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 checkbox with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/checkbox"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/checkbox"

Questions

How does the animated Checkbox for UI SDK move?

Pop: The filled box pops in. Draw: The check draws itself just after; the mixed state draws a dash. Press: The box shrinks slightly while pressed.

Do I need Motion or Framer Motion for the animated Checkbox?

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/checkbox instead. It has the same parts and props as @ui-sdk/react/checkbox and adds motion only.

What happens to the Checkbox when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page