Skip to content

Instantly share code, notes, and snippets.

@snigo
Created October 6, 2023 08:09
Show Gist options
  • Save snigo/28fd2869f28246d108e47ef32e416155 to your computer and use it in GitHub Desktop.
Save snigo/28fd2869f28246d108e47ef32e416155 to your computer and use it in GitHub Desktop.
SOLID React article, code snippet 6: Button component with variant
interface ButtonProps
extends React.PropsWithChildren,
React.HTMLAttributes<HTMLButtonElement> {
variant?: 'solid' | 'outlined' | 'blank';
onClick: React.MouseEventHandler<HTMLButtonElement>;
}
export const Button: React.FunctionComponent<ButtonProps> = ({
children,
variant = 'blank',
onClick,
...props
}) => {
const className = resolveClassName(variant);
return (
<button className={className} onClick={onClick} {...props}>
{children}
</button>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment