Components / Inputs
Animated Checkbox
A checkbox whose checkmark draws itself, with an optional animated strike-through.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/animated-checkbox.tsx. - 3
Use it
example.tsximport { AnimatedCheckbox } from "@/components/ui/animated-checkbox"; export default function AnimatedCheckboxDemo() { return ( <div className="flex flex-col gap-4"> <AnimatedCheckbox label="Design the landing page" strike defaultChecked /> <AnimatedCheckbox label="Build the components" strike /> <AnimatedCheckbox label="Ship it π" strike /> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| label | ReactNode | β | Text next to the box. |
| checked | boolean | β | Controlled value. Omit to let it manage itself. |
| defaultChecked | boolean | false | Starting value when uncontrolled. |
| onChange | (checked: boolean) => void | β | Called when toggled. |
| strike | boolean | false | Strike through the label when checked. |