返回 AiToEarn
checkbox.tsx
根目录 / project / aitoearn-web / src / components / ui / checkbox.tsx
1 'use client'
2
3 import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
4 import { Check } from 'lucide-react'
5 import * as React from 'react'
6
7 import { cn } from '@/utils/className'
8
9 const Checkbox = React.forwardRef<
10 React.ElementRef<typeof CheckboxPrimitive.Root>,
11 React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
12 >(({ className, ...props }, ref) => (
13 <CheckboxPrimitive.Root
14 ref={ref}
15 className={cn(
16 'grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-brand-purple/35 data-[state=checked]:bg-brand-purple/15 data-[state=checked]:text-brand-purple',
17 className,
18 )}
19 {...props}
20 >
21 <CheckboxPrimitive.Indicator className={cn('grid place-content-center text-current')}>
22 <Check className="h-4 w-4" />
23 </CheckboxPrimitive.Indicator>
24 </CheckboxPrimitive.Root>
25 ))
26 Checkbox.displayName = CheckboxPrimitive.Root.displayName
27
28 export { Checkbox }
29
29 lines Plain Text