diff --git a/src/components/ui/button/button.stories.tsx b/src/components/ui/button/button.stories.tsx index d9e8250..f62d9ae 100644 --- a/src/components/ui/button/button.stories.tsx +++ b/src/components/ui/button/button.stories.tsx @@ -47,6 +47,18 @@ export const Primary = { }, }; +export const PrimaryLoading = { + ...Template, + args: { + size: "default", + variant: "default", + onClick: () => { + console.log("on click"); + }, + isLoading: true, + }, +}; + export const Secondary = { ...Template, args: { diff --git a/src/components/ui/button/button.tsx b/src/components/ui/button/button.tsx index 4a7ff78..18302fc 100644 --- a/src/components/ui/button/button.tsx +++ b/src/components/ui/button/button.tsx @@ -37,17 +37,29 @@ interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { asChild?: boolean; + isLoading?: boolean; } export const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { + ({ className, variant, size, asChild = false, isLoading, ...props }, ref) => { const Comp = asChild ? Slot : "button"; return ( + > + {isLoading ? ( +
+
+
+ Loading +
+
+ ) : ( + props.children + )} + ); } ); diff --git a/tailwind.config.js b/tailwind.config.js index 0944668..395b095 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -57,6 +57,15 @@ module.exports = { disabled: "0.5", default: "0.5", }, + keyframes: { + spin: { + from: { transform: "rotate(0deg)" }, + to: { transform: "rotate(360deg)" }, + }, + }, + animation: { + spin: "spin 1s linear infinite;", + }, borderRadius: { lg: "8px", md: "6px",