A toggle control with drawn-check animation, indeterminate state, and full form integration via hidden native input.
Dependencies
Interaction Type
Click or Space/Enter to toggle. Supports checked, unchecked, and indeterminate states. Drawn check glyph animates on toggle with spring physics. Respects reduced motion.
Props
Options you can pass to customize this component.
checkedControlled checked state. Omit for uncontrolled.
defaultCheckedInitial checked state for uncontrolled usage.
onCheckedChangeCallback when the checked state changes.
nameForm field name for the hidden native input.
disabledDisables the checkbox.
requiredMarks the field as required for form validation.
aria-invalidIndicates validation error state.
aria-describedbyID of the element describing the checkbox.
classNameAdditional CSS classes merged via cn().
Installation
How to use
import { Checkbox, CheckboxField } from "@/components/ui/checkbox"
export function Demo() {
return (
<div className="flex flex-col gap-4">
<CheckboxField label="Accept terms" description="You agree to our Terms.">
<Checkbox name="terms" required />
</CheckboxField>
<CheckboxField label="Subscribe to updates">
<Checkbox name="subscribe" defaultChecked />
</CheckboxField>
</div>
)
}Source Code
Click the code icon in the top-right corner to view the source code.
License & Usage
// No code loaded.