1 import React from "react";
2 import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
3 import { Circle } from "lucide-react";
4 import { cn } from "@/lib/utils";
5
6 const RadioGroup = React.forwardRef<
7 React.ElementRef<typeof RadioGroupPrimitive.Root>,
8 React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
9 >(({ className, ...props }, ref) => {
10 return (
11 <RadioGroupPrimitive.Root
12 className={cn("grid gap-2", className)}
13 {...props}
14 ref={ref}
15 />
16 );
17 });
18 RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
19
20 const RadioGroupItem = React.forwardRef<
21 React.ElementRef<typeof RadioGroupPrimitive.Item>,
22 React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
23 >(({ className, ...props }, ref) => {
24 return (
25 <RadioGroupPrimitive.Item
26 ref={ref}
27 className={cn(
28 "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
29 className
30 )}
31 {...props}
32 >
33 <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
34 <Circle className="h-2.5 w-2.5 fill-current text-current" />
35 </RadioGroupPrimitive.Indicator>
36 </RadioGroupPrimitive.Item>
37 );
38 });
39 RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
40
41 export { RadioGroup, RadioGroupItem };