checkbox.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. "use client";
  2. import * as React from "react";
  3. import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
  4. import { Check } from "lucide-react";
  5. import { cn } from "@/lib/utils";
  6. const Checkbox = React.forwardRef<
  7. React.ElementRef<typeof CheckboxPrimitive.Root>,
  8. React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
  9. >(({ className, ...props }, ref) => (
  10. <CheckboxPrimitive.Root
  11. ref={ref}
  12. className={cn(
  13. "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
  14. className
  15. )}
  16. {...props}
  17. >
  18. <CheckboxPrimitive.Indicator
  19. className={cn("flex items-center justify-center text-current")}
  20. >
  21. <Check className="h-4 w-4" />
  22. </CheckboxPrimitive.Indicator>
  23. </CheckboxPrimitive.Root>
  24. ));
  25. Checkbox.displayName = CheckboxPrimitive.Root.displayName;
  26. export { Checkbox };