ButtonSelect.tsx 674 B

1234567891011121314151617181920212223242526272829303132
  1. import React from "react";
  2. export function ButtonSelect<T>({
  3. options,
  4. value,
  5. onChange,
  6. group,
  7. }: {
  8. options: { value: T; text: string }[];
  9. value: T | null;
  10. onChange: (value: T) => void;
  11. group: string;
  12. }) {
  13. return (
  14. <div className="buttonList">
  15. {options.map((option) => (
  16. <label
  17. key={option.text}
  18. className={value === option.value ? "active" : ""}
  19. >
  20. <input
  21. type="radio"
  22. name={group}
  23. onChange={() => onChange(option.value)}
  24. checked={value === option.value ? true : false}
  25. />
  26. {option.text}
  27. </label>
  28. ))}
  29. </div>
  30. );
  31. }