Spaces:
Runtime error
Runtime error
Create components/ui/radio-group.tsx
Browse files
components/ui/radio-group.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
| 5 |
+
import { Circle } from "lucide-react"
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils"
|
| 8 |
+
|
| 9 |
+
const RadioGroup = React.forwardRef<
|
| 10 |
+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
| 11 |
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
| 12 |
+
>(({ className, ...props }, ref) => {
|
| 13 |
+
return (
|
| 14 |
+
<RadioGroupPrimitive.Root
|
| 15 |
+
className={cn("grid gap-2", className)}
|
| 16 |
+
{...props}
|
| 17 |
+
ref={ref}
|
| 18 |
+
/>
|
| 19 |
+
)
|
| 20 |
+
})
|
| 21 |
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
| 22 |
+
|
| 23 |
+
const RadioGroupItem = React.forwardRef<
|
| 24 |
+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
| 25 |
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
| 26 |
+
>(({ className, ...props }, ref) => {
|
| 27 |
+
return (
|
| 28 |
+
<RadioGroupPrimitive.Item
|
| 29 |
+
ref={ref}
|
| 30 |
+
className={cn(
|
| 31 |
+
"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",
|
| 32 |
+
className
|
| 33 |
+
)}
|
| 34 |
+
{...props}
|
| 35 |
+
>
|
| 36 |
+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
| 37 |
+
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
| 38 |
+
</RadioGroupPrimitive.Indicator>
|
| 39 |
+
</RadioGroupPrimitive.Item>
|
| 40 |
+
)
|
| 41 |
+
})
|
| 42 |
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
|
| 43 |
+
|
| 44 |
+
export { RadioGroup, RadioGroupItem }
|