Add isIconOnly to Button.jsx

This commit is contained in:
Mathias Wagner
2025-09-09 13:31:19 +02:00
parent da6fe42d30
commit 8d97de06fd
2 changed files with 18 additions and 1 deletions

View File

@@ -16,6 +16,8 @@ export const Button = ({
...rest
}) => {
const isDisabled = disabled || loading;
const isIconOnly = (icon || iconRight) && !children;
return (
<Component
className={cn(
@@ -24,6 +26,7 @@ export const Button = ({
`btn--${size}`,
full && "btn--full",
loading && "is-loading",
isIconOnly && "btn--icon-only",
className
)}
disabled={isDisabled}
@@ -31,7 +34,7 @@ export const Button = ({
>
{loading && <span className="btn-spinner" aria-hidden />}
{icon && <span className="btn-icon btn-icon--left">{icon}</span>}
<span className="btn-label">{children}</span>
{children && <span className="btn-label">{children}</span>}
{iconRight && <span className="btn-icon btn-icon--right">{iconRight}</span>}
</Component>
);

View File

@@ -69,6 +69,20 @@
--c-text: #ffffff
background: var(--c-bg)
border-color: var(--c-border)
&.btn--icon-only
padding: 0.75rem
aspect-ratio: 1
justify-content: center
&.btn--sm
padding: 0.6rem
&.btn--lg
padding: 0.9rem
.btn-icon
margin: 0
.btn-icon
display: inline-flex