checkbox.tsx raw

   1  import * as React from "react";
   2  import { CheckIcon } from "lucide-react";
   3  import { Checkbox as CheckboxPrimitive } from "radix-ui";
   4  
   5  import { cn } from "src/lib/utils";
   6  
   7  function Checkbox({
   8    className,
   9    ...props
  10  }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
  11    return (
  12      <CheckboxPrimitive.Root
  13        data-slot="checkbox"
  14        className={cn(
  15          "peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary",
  16          className
  17        )}
  18        {...props}
  19      >
  20        <CheckboxPrimitive.Indicator
  21          data-slot="checkbox-indicator"
  22          className="grid place-content-center text-current transition-none"
  23        >
  24          <CheckIcon className="size-3.5" />
  25        </CheckboxPrimitive.Indicator>
  26      </CheckboxPrimitive.Root>
  27    );
  28  }
  29  
  30  export { Checkbox };
  31