51 lines
960 B
TypeScript
51 lines
960 B
TypeScript
import type { RadioButtonProps } from "$/types/InputTypes";
|
|
import { Radio } from "@headlessui/react";
|
|
import clsx from "clsx";
|
|
import { forwardRef } from "react";
|
|
|
|
|
|
const RadioButton = forwardRef<HTMLInputElement, RadioButtonProps>(({
|
|
id,
|
|
className,
|
|
labelClassName,
|
|
size = "sm",
|
|
value,
|
|
children
|
|
}, ref ) => {
|
|
return (
|
|
<Radio
|
|
id={id}
|
|
value={value}
|
|
className="group flex flex-row items-center justify-center gap-x-2 cursor-pointer"
|
|
ref={ref}
|
|
>
|
|
<div
|
|
className={clsx(
|
|
"rounded-full not-group-data-checked:border",
|
|
className,
|
|
{
|
|
"": size === "none",
|
|
"size-3": size === "xs",
|
|
"size-4": size === "sm",
|
|
"size-5": size === "md",
|
|
"size-6": size === "lg",
|
|
"size-7": size === "xl"
|
|
}
|
|
)}
|
|
/>
|
|
{
|
|
children &&
|
|
<div
|
|
className={labelClassName}
|
|
>
|
|
{children}
|
|
</div>
|
|
}
|
|
</Radio>
|
|
);
|
|
});
|
|
|
|
RadioButton.displayName = "RadioButton";
|
|
|
|
export default RadioButton;
|