UI/button: make children optional, fix layout shift

This commit is contained in:
Johannes Kirschbauer
2024-11-26 13:55:40 +01:00
parent ce12fbd19b
commit ea98e6d190

View File

@@ -39,7 +39,7 @@ const sizePaddings: Record<Size, string> = {
interface ButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: Variants;
size?: Size;
children: JSX.Element;
children?: JSX.Element;
startIcon?: JSX.Element;
endIcon?: JSX.Element;
class?: string;
@@ -67,9 +67,9 @@ export const Button = (props: ButtonProps) => {
)}
{...other}
>
<span class="h-4">{local.startIcon}</span>
<span>{local.children}</span>
<span class="h-4">{local.endIcon}</span>
{local.startIcon && <span class="h-4">{local.startIcon}</span>}
{local.children && <span>{local.children}</span>}
{local.endIcon && <span class="h-4">{local.endIcon}</span>}
</button>
);
};