hsuanyi-chou / shadcn-ui-expansions

More components built on top of shadcn-ui.
https://shadcnui-expansions.typeart.cc/
MIT License
1.1k stars 51 forks source link

Existing size option not applied when using Loading Button #63

Closed deogk closed 7 months ago

deogk commented 8 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>
hsuanyi-chou commented 7 months ago

There's a slot inside the loading-button. Size also works.

deogk commented 7 months ago

@hsuanyi-chou Does size work with variant="link"?

hsuanyi-chou commented 7 months ago

yes. You can add a border in className to see the result.