34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { ButtonHTMLAttributes, forwardRef } from 'react';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: 'default' | 'outline' | 'destructive';
|
|
size?: 'default' | 'sm' | 'lg';
|
|
}
|
|
|
|
const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
({ className, variant = 'default', size = 'default', ...props }, ref) => {
|
|
return (
|
|
<button
|
|
className={cn(
|
|
'inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
|
{
|
|
'bg-primary text-primary-foreground hover:bg-primary/90': variant === 'default',
|
|
'border border-input bg-background hover:bg-accent hover:text-accent-foreground': variant === 'outline',
|
|
'bg-destructive text-destructive-foreground hover:bg-destructive/90': variant === 'destructive',
|
|
'h-10 px-4 py-2': size === 'default',
|
|
'h-9 rounded-md px-3': size === 'sm',
|
|
'h-11 rounded-md px-8': size === 'lg',
|
|
},
|
|
className
|
|
)}
|
|
ref={ref}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
);
|
|
|
|
Button.displayName = 'Button';
|
|
|
|
export { Button };
|