Primitives
Checkbox
Radix checkbox with a springy check, indeterminate state, and the brand fill.
Motionindicator scale-in on spring.bouncy
Install
Install Kineto and follow the theme setup once in your app.
bash
npm install kinetotsx
import { Checkbox } from "kineto/checkbox";Preview
tsx
"use client";
import * as React from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { Check, Minus } from "lucide-react";
import { motion } from "motion/react";
import { cn } from "@/lib/cn";
import { spring } from "@/lib/motion-presets";
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"group peer size-5 shrink-0 rounded-[6px] border border-input bg-card shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-brand data-[state=checked]:bg-brand data-[state=checked]:text-brand-foreground data-[state=indeterminate]:border-brand data-[state=indeterminate]:bg-brand data-[state=indeterminate]:text-brand-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator asChild>
<motion.span
initial={{ scale: 0.4, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={spring.bouncy}
className="flex items-center justify-center text-current"
>
<Check className="size-3.5 group-data-[state=indeterminate]:hidden" strokeWidth={3} />
<Minus className="hidden size-3.5 group-data-[state=indeterminate]:block" strokeWidth={3} />
</motion.span>
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
));
Checkbox.displayName = "Checkbox";
export { Checkbox };src/components/ui/checkbox.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| checked / defaultChecked | boolean | 'indeterminate' | — | Controlled or uncontrolled state. |
| onCheckedChange | (checked) => void | — | Fires on toggle. |