Files
frontend/packages/common/components/src/ui/button-group/index.tsx
T

40 lines
1.1 KiB
TypeScript

import "./button-group.css";
import * as React from "react";
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
const ButtonGroup = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> & {
variant?: "radio" | "button";
color?: "primary" | "secondary";
shape?: "square" | "rounded";
}
>(
(
{ variant = "radio", color = "primary", shape = "square", ...props },
ref,
) => {
return (
<RadioGroupPrimitive.Root
{...props}
ref={ref}
data-variant={variant}
data-color={color}
data-shape={shape}
/>
);
},
);
ButtonGroup.displayName = RadioGroupPrimitive.Root.displayName;
const ButtonGroupItem = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
>(({ ...props }, ref) => {
return <RadioGroupPrimitive.Item ref={ref} {...props} />;
});
ButtonGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
export { ButtonGroup, ButtonGroupItem };