Closed deogk closed 7 months ago
<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>
add a Slottable component link: https://www.radix-ui.com/primitives/docs/utilities/slot
<Comp className={cn(buttonVariants({ variant, size, className }))} disabled={loading} ref={ref} {...props} > {loading ? ( <Slottable> <Loader2 className={cn('h-4 w-4 animate-spin', children && 'mr-2')} /> {children} </Slottable> ) : ( <Slottable>{children}</Slottable> )} </Comp>
There's a slot inside the loading-button. Size also works.
loading-button
Size
@hsuanyi-chou Does size work with variant="link"?
variant="link"
yes. You can add a border in className to see the result.
border
add a Slottable component link: https://www.radix-ui.com/primitives/docs/utilities/slot