Checkbox
basecn/checkboxFreeComponent
A control that allows the user to toggle between checked and not checked.
Live preview
live · rendered by the registry
Rendered by basecn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://basecn.dev/r/checkbox.jsonSource
1import * as React from "react";2import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";3import { CheckIcon } from "lucide-react";45import { cn } from "@/lib/utils";67function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {8 return (9 <CheckboxPrimitive.Root10 data-slot="checkbox"11 className={cn(12 "peer border-input dark:bg-input/30 data-[checked]:bg-primary data-[checked]:text-primary-foreground dark:data-[checked]:bg-primary data-[checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",13 className14 )}15 {...props}16 >17 <CheckboxPrimitive.Indicator18 data-slot="checkbox-indicator"19 className="size-full flex items-center justify-center text-current transition-none"20 >21 <CheckIcon className="size-3.5" />22 </CheckboxPrimitive.Indicator>23 </CheckboxPrimitive.Root>24 );25}2627export { Checkbox };
What it pulls in
npm packages
Files it writes
More from basecn
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | basecn | Components | Free | 2 deps | |
| Alertalert | basecn | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | basecn | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | basecn | Components | Free | no deps | |
| Autocompleteautocomplete | basecn | Components | Free | 2 deps | |
| Avataravatar | basecn | Components | Free | 1 dep | |
| Badgebadge | basecn | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | basecn | Components | Free | 2 deps |
