Fixed button layout to have loading the same size as the original button
This commit is contained in:
parent
5b83bde64e
commit
cad4c508a9
1 changed files with 11 additions and 4 deletions
|
|
@ -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
|
||||
)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue