Primitives/Checkbox
Checkbox
Base UI checkbox with an enlarged hit area.
- Version
- 1.0.1
- Tier
- Primitive
- Updates taken
- Minor and patch
- Files
- 1
Preview
Install
In a project already set up on the contract, which is what registers the @ja3dan prefix. If yours isn't, set it up first.
bunx shadcn@latest add @ja3dan/checkbox Also installs @base-ui/react lucide-react if the project doesn't have them.
Source
What lands in your project, read from the published item rather than the working tree.
"use client";import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";import { CheckIcon } from "lucide-react";import { cn } from "@/lib/utils";function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) { return ( <CheckboxPrimitive.Root data-slot="checkbox" className={cn( "peer relative flex size-4 shrink-0 items-center justify-center rounded-sm border border-input bg-card transition-[background-color,border-color] duration-150 ease-out outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground", className, )} {...props} > <CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="grid place-content-center text-current transition-none [&>svg]:size-3" > <CheckIcon /> </CheckboxPrimitive.Indicator> </CheckboxPrimitive.Root> );}export { Checkbox };