ButtonSelect.tsx 504 B

12345678910111213141516171819202122232425
  1. import React from "react";
  2. export function ButtonSelect<T>({
  3. options,
  4. value,
  5. onChange
  6. }: {
  7. options: { value: T; text: string }[];
  8. value: T | null;
  9. onChange: (value: T) => void;
  10. }) {
  11. return (
  12. <div className="buttonList">
  13. {options.map(option => (
  14. <button
  15. key={option.text}
  16. onClick={() => onChange(option.value)}
  17. className={value === option.value ? "active" : ""}
  18. >
  19. {option.text}
  20. </button>
  21. ))}
  22. </div>
  23. );
  24. }