Closed lok225 closed 9 months ago
It's fixed. Missing fragment
.
Thanks!
Following is a snippet so that you don't have to copy it again.
<Comp
className={cn(buttonVariants({ variant, size, className }))}
disabled={loading}
ref={ref}
{...props}
>
+ <>
{loading && <Loader2 className={cn('h-4 w-4 animate-spin', children && 'mr-2')} />}
{children}
+ </>
</Comp>
Adding this fragment breaks styles when actually using asChild with NextJS Link for me.
<Button variant="outline" asChild className="ml-auto gap-1">
<Link href="/">
<Plus />
New
</Link>
</Button>
the button does not have outline styles nor classname styles
@Yhprum
fix it.
please copy the loading-button.tsx
again.
thanks you! works great
When implementing the LoadingButton with the asChild prop, you get the following error. I guess the current implementation negates the Slot implementation when using asChild:
const LoadingButton = React.forwardRef<HTMLButtonElement, ButtonProps>( ({ className, variant, size, asChild = false, loading, children, ...props }, ref) => { const Comp = asChild ? Slot : 'button'; return ( <Comp className={cn(buttonVariants({ variant, size, className }))} disabled={loading} ref={ref} {...props}