excalidraw/src/components/ButtonSelect.tsx

33 lines
674 B
TypeScript
Raw Normal View History

import React from "react";
export function ButtonSelect<T>({
options,
value,
2020-01-24 12:04:54 +02:00
onChange,
group,
}: {
options: { value: T; text: string }[];
value: T | null;
onChange: (value: T) => void;
group: string;
}) {
return (
<div className="buttonList">
{options.map((option) => (
<label
key={option.text}
className={value === option.value ? "active" : ""}
>
<input
type="radio"
name={group}
onChange={() => onChange(option.value)}
checked={value === option.value ? true : false}
/>
{option.text}
</label>
))}
</div>
);
}