Files
shared/packages/web-ui/src/lib/components/Button.svelte
T

38 lines
975 B
Svelte
Raw Normal View History

2026-08-04 15:17:15 +02:00
<script lang="ts">
import type { HTMLButtonAttributes } from 'svelte/elements';
2026-08-04 15:17:15 +02:00
import type { Snippet } from 'svelte';
type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger';
type ButtonSize = 'sm' | 'md' | 'lg' | 'icon';
2026-08-04 15:17:15 +02:00
let {
children,
class: className = '',
disabled = false,
fullWidth = false,
onclick,
size = 'md',
type = 'button',
variant = 'primary',
...rest
}: Omit<HTMLButtonAttributes, 'class' | 'disabled' | 'onclick' | 'type'> & {
2026-08-04 15:17:15 +02:00
children?: Snippet;
class?: string;
disabled?: boolean;
fullWidth?: boolean;
onclick?: (event: MouseEvent) => void;
size?: ButtonSize;
type?: 'button' | 'submit' | 'reset';
variant?: ButtonVariant;
} = $props();
</script>
<button
class={`sc-button sc-button-${variant} sc-button-${size}${fullWidth ? ' sc-button-full' : ''} ${className}`}
{disabled}
{onclick}
{type}
{...rest}
2026-08-04 15:17:15 +02:00
>
{@render children?.()}
</button>