dssoca docs
GitHub repository

Button

The primary action control.

Four variants — primary, secondary, ghost, danger. Square edges, token-driven padding. Supports a `loading` state that renders the shared `Spinner` (aria-busy, stays focusable) and accepts `true` (the configured default variant) or a `SpinnerVariant` string, leading/trailing icon snippets that never change the control height, `iconOnly` and `fullWidth` layouts, a bindable element ref, and forwards any remaining native button attributes.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { Button } from 'dssoca';
</script>

<Button variant="primary" onclick={() => {}}>deploy</Button>
<Button variant="secondary">cancel</Button>
<Button variant="danger" loading loadingLabel="deleting…">delete</Button>
<Button variant="primary" loading="pipe" loadingLabel="saving…">save</Button>
<Button variant="ghost">forgot?</Button>

Props

PropTypeDefaultDescription
variant'primary' | 'secondary' | 'ghost' | 'danger''secondary'Visual emphasis.
type'button' | 'submit' | 'reset''button'Native button type.
disabledbooleanfalseDisable the button.
loadingboolean | SpinnerVariantfalseLoading state, rendered with the shared Spinner: `true` uses the configured default variant, a SpinnerVariant string picks a glyph, `false` is off. Blocks clicks, sets aria-busy; the button stays focusable. (BREAKING since 0.x: was a plain boolean and a bespoke ring spinner.)
loadingLabelstringAccessible name while loading (keeps the name stable when the label is hidden).
iconOnlybooleanfalseSquare icon-only button; `label` is required and becomes the aria-label.
labelstringAccessible name; required for icon-only buttons.
fullWidthbooleanfalseStretch to fill the inline axis and centre the content.
leadingSnippetIcon snippet rendered before children.
trailingSnippetIcon snippet rendered after children.
onclick(e: MouseEvent) => voidClick handler (suppressed while loading/disabled).
elHTMLButtonElementBindable reference to the underlying <button>.
size'sm' | 'md' | 'lg'Per-instance size override; inherits the ancestor `data-size-variant` when unset.
childrenSnippetButton label.
...restHTMLButtonAttributesAny remaining native button attributes / handlers are forwarded.