infoalloggi-monorepo/apps/infoalloggi/src/components/custom_ui/loading-button.tsx

35 lines
607 B
TypeScript
Raw Normal View History

2025-08-28 18:27:07 +02:00
import { LoaderCircle } from "lucide-react";
2025-08-04 17:45:44 +02:00
import {
2025-08-28 18:27:07 +02:00
Button,
type ButtonProps,
buttonVariants,
2025-08-04 17:45:44 +02:00
} from "~/components/ui/button";
import { cn } from "~/lib/utils";
const LoadingButton = ({
2025-08-28 18:27:07 +02:00
className,
variant,
size,
loading,
...props
2025-08-04 17:45:44 +02:00
}: ButtonProps & { loading?: boolean }) => {
2025-08-28 18:27:07 +02:00
return (
<Button
className={cn(buttonVariants({ variant, size, className }))}
{...props}
>
{loading && (
<LoaderCircle
className="-ms-1 me-2 animate-spin"
size={16}
strokeWidth={2}
aria-hidden="true"
/>
)}
{props.children}
</Button>
);
2025-08-04 17:45:44 +02:00
};
export default LoadingButton;