1
6import * as React from "react";
7import * as RadixCheckbox from "@radix-ui/react-checkbox";
8import { clsx } from "clsx";
9
10export const Checkbox = React.forwardRef<
11 React.ElementRef<typeof RadixCheckbox.Root>,
12 React.ComponentPropsWithoutRef<typeof RadixCheckbox.Root>
13>(({ className, ...props }, ref) => (
14 <RadixCheckbox.Root
15 ref={ref}
16 className={clsx(
17 "group h-4 w-4 shrink-0 rounded-sm border border-input",
18 "flex cursor-pointer items-center justify-center",
19 "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",
20 "disabled:cursor-not-allowed disabled:opacity-50",
21 "data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=checked]:text-primary-foreground",
22 "data-[state=indeterminate]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:text-primary-foreground",
23 className,
24 )}
25 {...props}
26 >
27 <RadixCheckbox.Indicator>
28 <span className="text-[10px] leading-none group-data-[state=indeterminate]:hidden">✓</span>
29 <span className="hidden text-[10px] leading-none group-data-[state=indeterminate]:block">
30 –
31 </span>
32 </RadixCheckbox.Indicator>
33 </RadixCheckbox.Root>
34));
35Checkbox.displayName = "Checkbox";
36