feat: button variants

This commit is contained in:
2025-05-24 16:15:00 +02:00
parent 3bcc5f8900
commit e6b87a6561

View File

@ -1,20 +1,40 @@
import type { ButtonHTMLAttributes, FC, ReactNode } from "react"; import {
useMemo,
type ButtonHTMLAttributes,
type FC,
type ReactNode,
} from "react";
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
children: ReactNode; children: ReactNode;
className?: string; className?: string;
loading?: boolean; loading?: boolean;
variant?: "contained" | "outlined" | "text";
} }
export const Button: FC<ButtonProps> = ({ export const Button: FC<ButtonProps> = ({
children, children,
className, className,
loading, loading,
variant = "contained",
...props ...props
}) => { }) => {
const appearance = useMemo(() => {
switch (variant) {
case "contained":
return "bg-blue-600 text-white hover:bg-blue-700";
case "outlined":
return "border border-blue-600 text-blue-600 hover:text-blue-700 font-medium";
case "text":
return "text-blue-600 hover:text-blue-700 font-medium";
}
return "";
}, [variant]);
return ( return (
<button <button
className={`bg-blue-600 text-white cursor-pointer py-2 px-4 rounded-md hover:bg-blue-700 transition-colors ${ className={`cursor-pointer py-2 px-4 rounded-md transition-colors ${appearance} ${
className || "" className || ""
}${ }${
loading loading