blob: 6e25b1859d58eefaffe25723d2e093b17e2a325b [file] [log] [blame]
gio43e0aad2025-08-01 16:17:27 +04001import * as React from "react";
2import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
3import { cn } from "@/lib/utils";
4import { DotFilledIcon } from "@radix-ui/react-icons";
5
6const RadioGroup = React.forwardRef<
7 React.ElementRef<typeof RadioGroupPrimitive.Root>,
8 React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
9>(({ className, ...props }, ref) => {
10 return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />;
11});
12RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
13
14const RadioGroupItem = React.forwardRef<
15 React.ElementRef<typeof RadioGroupPrimitive.Item>,
16 React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
17>(({ className, ...props }, ref) => {
18 return (
19 <RadioGroupPrimitive.Item
20 ref={ref}
21 className={cn(
22 "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",
23 className,
24 )}
25 {...props}
26 >
27 <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
28 <DotFilledIcon className="h-3.5 w-3.5 fill-primary" />
29 </RadioGroupPrimitive.Indicator>
30 </RadioGroupPrimitive.Item>
31 );
32});
33RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
34
35export { RadioGroup, RadioGroupItem };