Button.tsx 775 B

1234567891011121314151617181920212223242526272829303132333435
  1. import "./Button.scss";
  2. interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
  3. type?: "button" | "submit" | "reset";
  4. onSelect: () => any;
  5. children: React.ReactNode;
  6. className?: string;
  7. }
  8. /**
  9. * A generic button component that follows Excalidraw's design system.
  10. * Style can be customised using `className` or `style` prop.
  11. * Accepts all props that a regular `button` element accepts.
  12. */
  13. export const Button = ({
  14. type = "button",
  15. onSelect,
  16. children,
  17. className = "",
  18. ...rest
  19. }: ButtonProps) => {
  20. return (
  21. <button
  22. onClick={(event) => {
  23. onSelect();
  24. rest.onClick?.(event);
  25. }}
  26. type={type}
  27. className={`excalidraw-button ${className}`}
  28. {...rest}
  29. >
  30. {children}
  31. </button>
  32. );
  33. };