Fixed button layout to have loading the same size as the original button

This commit is contained in:
Lucas Oliveira 2024-06-04 11:35:37 -03:00
commit cad4c508a9

View file

@ -68,10 +68,17 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
{...props}
>
{loading ? (
<ForwardedIconComponent
name={"Loader2"}
className={"animate-spin"}
/>
<span className={cn("relative")}>
<span className={loading ? "invisible" : "hidden"}>
{newChildren}
</span>
<span className="absolute inset-0 flex items-center justify-center">
<ForwardedIconComponent
name={"Loader2"}
className={"animate-spin"}
/>
</span>
</span>
) : (
newChildren
)}