checkbox.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. "use client"
  2. import * as React from "react"
  3. import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
  4. import { CheckIcon } from "lucide-react"
  5. import { cn } from "@/lib/utils"
  6. function Checkbox({
  7. className,
  8. ...props
  9. }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
  10. return (
  11. <CheckboxPrimitive.Root
  12. data-slot="checkbox"
  13. className={cn(
  14. "peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=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",
  15. className
  16. )}
  17. {...props}
  18. >
  19. <CheckboxPrimitive.Indicator
  20. data-slot="checkbox-indicator"
  21. className="flex items-center justify-center text-current transition-none"
  22. >
  23. <CheckIcon className="size-3.5" />
  24. </CheckboxPrimitive.Indicator>
  25. </CheckboxPrimitive.Root>
  26. )
  27. }
  28. export { Checkbox }