Skip to main content

Button

Button.tsx
import React, { useRef } from 'react';
import styles from './Button.module.css';

interface ButtonProps {
label: string;
onClick?: () => void;
}

const Button = ({ label, onClick }: ButtonProps) => {
const buttonRef = useRef<HTMLButtonElement>(null);

const handleClick = () => {
if (onClick) {
onClick();
}
};

return (
<button className={styles.button} onClick={handleClick} ref={buttonRef}>
{label}
</button>
);
};

export default Button;


Button.module.css
.button {
padding: 8px 16px;
border-radius: 4px;
border: none;
background-color: #0077cc;
color: #fff;
font-size: 16px;
cursor: pointer;
}

.button:hover {
background-color: #005fa3;
}