checkbox.tsx 1.2 KB

123456789101112131415161718192021222324
  1. import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
  2. import { CheckIcon } from 'lucide-react';
  3. import * as React from 'react';
  4. import { cn } from '@/common/helpers/cn';
  5. function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
  6. return (
  7. <CheckboxPrimitive.Root
  8. data-slot="checkbox"
  9. className={cn(
  10. '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:aria-invalid:ring-destructive/40',
  11. className,
  12. )}
  13. {...props}
  14. >
  15. <CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="flex items-center justify-center text-current transition-none">
  16. <CheckIcon className="size-3.5" />
  17. </CheckboxPrimitive.Indicator>
  18. </CheckboxPrimitive.Root>
  19. );
  20. }
  21. export { Checkbox };