| 5 | import { cn } from "@/lib/utils"; |
| 6 | |
| 7 | function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) { |
| 8 | return ( |
| 9 | <CheckboxPrimitive.Root |
| 10 | className={cn( |
| 11 | "relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[4px] border border-input bg-background bg-clip-padding shadow-xs outline-none ring-ring transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[3px] not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none", |
| 12 | className, |
| 13 | )} |
| 14 | data-slot="checkbox" |
| 15 | {...props} |
| 16 | > |
| 17 | <CheckboxPrimitive.Indicator |
| 18 | className="-inset-px absolute flex items-center justify-center rounded-[4px] text-primary-foreground data-unchecked:hidden data-checked:bg-primary data-indeterminate:text-foreground" |
| 19 | data-slot="checkbox-indicator" |
| 20 | render={(props, state) => ( |
| 21 | <span {...props}> |
| 22 | {state.indeterminate ? ( |
| 23 | <svg |
| 24 | className="size-3.5 sm:size-3" |
| 25 | fill="none" |
| 26 | height="24" |
| 27 | stroke="currentColor" |
| 28 | strokeLinecap="round" |
| 29 | strokeLinejoin="round" |
| 30 | strokeWidth="3" |
| 31 | viewBox="0 0 24 24" |
| 32 | width="24" |
| 33 | xmlns="http://www.w3.org/2000/svg" |
| 34 | > |
| 35 | <path d="M5.252 12h13.496" /> |
| 36 | </svg> |
| 37 | ) : ( |
| 38 | <svg |
| 39 | className="size-3.5 sm:size-3" |
| 40 | fill="none" |
| 41 | height="24" |
| 42 | stroke="currentColor" |
| 43 | strokeLinecap="round" |
| 44 | strokeLinejoin="round" |
| 45 | strokeWidth="3" |
| 46 | viewBox="0 0 24 24" |
| 47 | width="24" |
| 48 | xmlns="http://www.w3.org/2000/svg" |
| 49 | > |
| 50 | <path d="M5.252 12.7 10.2 18.63 18.748 5.37" /> |
| 51 | </svg> |
| 52 | )} |
| 53 | </span> |
| 54 | )} |
| 55 | /> |
| 56 | </CheckboxPrimitive.Root> |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | export { Checkbox }; |