Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reusable UI Button component #1397

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';

type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'success';

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: ButtonVariant;
children?: React.ReactNode;
}

const Button: React.FC<ButtonProps> = ({
variant = 'primary',
children,
...props
}) => {
const baseStyles =
'w-[170px] h-[45px] rounded border-2 bg-primary hover:bg-blue-700 transition-all duration-300 ease-in-out text-white font-semibold dark:border-none';

const variantStyles: Record<ButtonVariant, string> = {
primary: 'bg-primary dark:shadow-2xl',
secondary: 'bg-gray-500 hover:bg-gray-700',
danger: 'bg-red-500 hover:bg-red-700',
success: 'bg-green-500 hover:bg-green-700',
};

const buttonClass = `${baseStyles} ${variantStyles[variant] || variantStyles.primary}`;

return (
<button className={buttonClass} {...props}>
{children}
</button>
);
};

export default Button;