Skip to content

Commit

Permalink
fix(button): Slot cannot have more than 1 child
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjavi committed Sep 2, 2024
1 parent 2620bcc commit c1752e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,14 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
ref={ref}
{...props}
>
{loading && <LoaderCircle className="mr-2" />}
{children}
{loading ? (
<span className="flex items-center">
<LoaderCircle className="mr-2" />
{children}
</span>
) : (
children
)}
</Comp>
);
},
Expand Down
4 changes: 2 additions & 2 deletions stories/button/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const Default: Story = {
<Button variant="ghost" {...args}>
Ghost
</Button>
<Button variant="link" {...args}>
Link
<Button variant="link" {...args} asChild>
<a href="https://localhost:3000">Link</a>
</Button>
</div>
),
Expand Down

0 comments on commit c1752e8

Please sign in to comment.