返回 AiToEarn
radio-group.tsx
根目录 / project / aitoearn-web / src / components / ui / radio-group.tsx
1 'use client'
2
3 import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'
4 import { Circle } from 'lucide-react'
5 import * as React from 'react'
6
7 import { cn } from '@/utils/className'
8
9 const RadioGroup = React.forwardRef<
10 React.ElementRef<typeof RadioGroupPrimitive.Root>,
11 React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
12 >(({ className, ...props }, ref) => {
13 return <RadioGroupPrimitive.Root className={cn('grid gap-2', className)} {...props} ref={ref} />
14 })
15 RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
16
17 const RadioGroupItem = React.forwardRef<
18 React.ElementRef<typeof RadioGroupPrimitive.Item>,
19 React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
20 >(({ className, ...props }, ref) => {
21 return (
22 <RadioGroupPrimitive.Item
23 ref={ref}
24 className={cn(
25 'aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
26 className,
27 )}
28 {...props}
29 >
30 <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
31 <Circle className="h-3.5 w-3.5 fill-primary" />
32 </RadioGroupPrimitive.Indicator>
33 </RadioGroupPrimitive.Item>
34 )
35 })
36 RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
37
38 export { RadioGroup, RadioGroupItem }
39
39 lines Plain Text