gitscope
← marzneshin / v0.5.5 / dashboard/src/components/ui/radio-group.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/components/ui/radio-group.tsx · TypeScript
Blame Raw
 1import * as React from "react"
 2import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
 3import { Circle } from "lucide-react"
 4
 5import { cn } from "@marzneshin/utils"
 6
 7const RadioGroup = React.forwardRef<
 8  React.ElementRef<typeof RadioGroupPrimitive.Root>,
 9  React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
10>(({ className, ...props }, ref) => {
11  return (
12    <RadioGroupPrimitive.Root
13      className={cn("grid gap-2", className)}
14      {...props}
15      ref={ref}
16    />
17  )
18})
19RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
20
21const RadioGroupItem = React.forwardRef<
22  React.ElementRef<typeof RadioGroupPrimitive.Item>,
23  React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
24>(({ className, ...props }, ref) => {
25  return (
26    <RadioGroupPrimitive.Item
27      ref={ref}
28      className={cn(
29        "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",
30        className
31      )}
32      {...props}
33    >
34      <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
35        <Circle className="h-2.5 w-2.5 fill-current text-current" />
36      </RadioGroupPrimitive.Indicator>
37    </RadioGroupPrimitive.Item>
38  )
39})
40RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
41
42export { RadioGroup, RadioGroupItem }