37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { ButtonHTMLAttributes, forwardRef } from "react";
|
|
|
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: "primary" | "secondary" | "outline";
|
|
size?: "sm" | "md" | "lg";
|
|
}
|
|
|
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
({ className = "", variant = "primary", size = "md", children, ...props }, ref) => {
|
|
const baseStyles = "rounded-md font-medium transition-colors focus:outline-none focus:ring-2";
|
|
|
|
const variantStyles = {
|
|
primary: "bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",
|
|
secondary: "bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500",
|
|
outline: "border border-gray-300 bg-transparent hover:bg-gray-50 focus:ring-gray-500",
|
|
};
|
|
|
|
const sizeStyles = {
|
|
sm: "px-3 py-1.5 text-sm",
|
|
md: "px-4 py-2 text-base",
|
|
lg: "px-6 py-3 text-lg",
|
|
};
|
|
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
className={`${baseStyles} ${variantStyles[variant]} ${sizeStyles[size]} ${className}`}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
},
|
|
);
|
|
|
|
Button.displayName = "Button";
|