aboutsummaryrefslogtreecommitdiffstats
path: root/packages/excalidraw/components/ButtonSelect.tsx
blob: c47ff65e7e535407fd2f746fcf7fa6c453884152 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import clsx from "clsx";

export const ButtonSelect = <T extends Object>({
  options,
  value,
  onChange,
  group,
}: {
  options: { value: T; text: string }[];
  value: T | null;
  onChange: (value: T) => void;
  group: string;
}) => (
  <div className="buttonList">
    {options.map((option) => (
      <label
        key={option.text}
        className={clsx({ active: value === option.value })}
      >
        <input
          type="radio"
          name={group}
          onChange={() => onChange(option.value)}
          checked={value === option.value}
        />
        {option.text}
      </label>
    ))}
  </div>
);