{"slug":"button","name":"Button","category":"Form & Input","summary":"Triggers an action or submits a form.","status":"stable","since":"0.1.0","import":"import { Button } from '@elluzion/iv-ui';","usage":["Keep one primary action per view; everything else stays `secondary` or `outline`.","Use `loading` for async work — it sets `aria-busy` and ignores clicks without removing the button from the tab order.","Icon-only buttons need an `aria-label`; the `icon` variant has no text to fall back on."],"props":[{"name":"variant","type":"'primary' | 'secondary' | 'outline' | 'ghost' | 'icon' | 'danger'","default":"'secondary'","description":"Visual emphasis. `secondary` is the default.","required":false,"bindable":false},{"name":"size","type":"'sm' | 'md' | 'lg'","default":"'md'","description":"Button height and padding.","required":false,"bindable":false},{"name":"disabled","type":"boolean","default":"false","description":"Disables interaction and applies the disabled treatment.","required":false,"bindable":false},{"name":"loading","type":"boolean","default":"false","description":"Shows a spinner, sets `aria-busy`, and ignores clicks.","required":false,"bindable":false},{"name":"className","type":"string","default":"''","description":"Extra classes merged onto the root element.","required":false,"bindable":false},{"name":"type","type":"'button' | 'submit' | 'reset'","default":"'button'","description":"Native button type.","required":false,"bindable":false}],"events":[{"name":"click","type":"(e: MouseEvent) => void","default":null,"description":"Called on activation with the native mouse event.","required":false,"bindable":false}],"snippets":[{"name":"children","type":"Snippet","default":null,"description":"Content rendered inside the component.","required":true,"bindable":false}],"types":[],"manual":[],"tokens":["--iv_border","--iv_border-hover","--iv_btn-pad-x","--iv_btn-pad-x-lg","--iv_btn-pad-x-sm","--iv_control-pad-y","--iv_control-pad-y-lg","--iv_control-pad-y-sm","--iv_disabled-opacity","--iv_ease-in-out","--iv_ease-out","--iv_error","--iv_error-dim","--iv_font-ui","--iv_foreground","--iv_foreground-dim","--iv_foreground-hover","--iv_radius-sm","--iv_ring","--iv_ring-width","--iv_spacing-sm","--iv_spacing-xs","--iv_surface","--iv_surface-elevated","--iv_surface-hover","--iv_surface-raised","--iv_text-btn-sm","--iv_text-lg","--iv_transition-base","--iv_transition-fast"],"cssHooks":["iv-btn-lg","iv-btn-sm","iv-danger","iv-disabled","iv-ghost","iv-icon","iv-loading","iv-outline","iv-primary"],"accessibility":{"keyboard":[["Tab","Moves focus to the button."],["Enter","Activates the button."],["Space","Activates the button."]],"notes":["Focus uses a visible ring; it is never removed.","A disabled button is removed from the tab order and does not fire clicks."]},"related":[{"title":"ButtonGroup","summary":"Joins related buttons into one segmented control.","url":"/components/button-group","kind":"Component"},{"title":"Toggle","summary":"A pressable button that keeps a checked state.","url":"/components/toggle","kind":"Component"},{"title":"Field","summary":"Labels a custom control and renders its helper or error message.","url":"/components/field","kind":"Component"},{"title":"Tooltip","summary":"A short label shown on hover or focus.","url":"/components/tooltip","kind":"Component"}],"examples":[{"id":"variants","title":"Variants","description":"Six levels of emphasis. `secondary` is the default.","code":"<script lang=\"ts\">\n\timport { IconDots } from '@tabler/icons-svelte';\n\timport { Button } from '@elluzion/iv-ui';\n</script>\n\n<div class=\"row\">\n\t<Button variant=\"primary\">Primary</Button>\n\t<Button>Secondary</Button>\n\t<Button variant=\"outline\">Outline</Button>\n\t<Button variant=\"ghost\">Ghost</Button>\n\t<Button variant=\"danger\">Danger</Button>\n\t<Button variant=\"icon\" aria-label=\"More actions\"><IconDots size={16} /></Button>\n</div>\n\n<style>\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n</style>"},{"id":"sizes","title":"Sizes","description":"`sm`, `md`, and `lg` share the same shape.","code":"<script lang=\"ts\">\n\timport { IconPlus } from '@tabler/icons-svelte';\n\timport { Button } from '@elluzion/iv-ui';\n</script>\n\n<div class=\"row\">\n\t<Button size=\"sm\" variant=\"primary\">Small</Button>\n\t<Button size=\"md\" variant=\"primary\">Medium</Button>\n\t<Button size=\"lg\" variant=\"primary\">Large</Button>\n</div>\n<div class=\"row\">\n\t<Button size=\"sm\" variant=\"outline\"><IconPlus size={14} /> New</Button>\n\t<Button size=\"md\" variant=\"outline\"><IconPlus size={16} /> New</Button>\n\t<Button size=\"lg\" variant=\"outline\"><IconPlus size={18} /> New</Button>\n</div>\n\n<style>\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n</style>"},{"id":"icons","title":"Icons","description":"Icons inherit the text size. Icon-only buttons use `variant=\"icon\"`.","code":"<script lang=\"ts\">\n\timport { IconArrowRight, IconDownload, IconSearch, IconTrash } from '@tabler/icons-svelte';\n\timport { Button } from '@elluzion/iv-ui';\n</script>\n\n<div class=\"row\">\n\t<Button variant=\"primary\"><IconDownload size={16} /> Export</Button>\n\t<Button variant=\"outline\">Continue <IconArrowRight size={16} /></Button>\n\t<Button variant=\"ghost\"><IconSearch size={16} /> Search</Button>\n\t<Button variant=\"danger\"><IconTrash size={16} /> Delete</Button>\n</div>\n<div class=\"row\">\n\t<Button variant=\"icon\" aria-label=\"Search\"><IconSearch size={18} /></Button>\n\t<Button variant=\"icon\" aria-label=\"Export\"><IconDownload size={18} /></Button>\n\t<Button variant=\"icon\" aria-label=\"Delete\" disabled><IconTrash size={18} /></Button>\n</div>\n\n<style>\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n</style>"},{"id":"loading","title":"Loading","description":"Spinner replaces the label and clicks are ignored while `loading` is true.","code":"<script lang=\"ts\">\n\timport { Button } from '@elluzion/iv-ui';\n\n\tlet saving = $state(false);\n\n\tasync function save() {\n\t\tsaving = true;\n\t\tawait new Promise((resolve) => setTimeout(resolve, 1200));\n\t\tsaving = false;\n\t}\n</script>\n\n<div class=\"row\">\n\t<Button variant=\"primary\" loading={saving} onclick={save}>\n\t\t{saving ? 'Saving…' : 'Save changes'}\n\t</Button>\n\t<Button variant=\"outline\" loading>Syncing</Button>\n\t<Button variant=\"secondary\" disabled>Unavailable</Button>\n</div>\n\n<style>\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n</style>"},{"id":"events","title":"Events","description":"`onclick` and the legacy `on:click` both receive the native mouse event.","code":"<script lang=\"ts\">\n\timport { Button } from '@elluzion/iv-ui';\n\n\tlet clicks = $state(0);\n\tlet legacy = $state(0);\n\n\t// Both props receive the same native event.\n\tconst handlers = {\n\t\tonclick: () => clicks++,\n\t\t'on:click': () => legacy++\n\t};\n</script>\n\n<div class=\"stack\">\n\t<Button variant=\"primary\" {...handlers}>Click me</Button>\n\t<p class=\"readout\">onclick {clicks} · on:click {legacy}</p>\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n\n\t.readout {\n\t\tmargin: 0;\n\t\tfont-size: var(--iv_text-xs);\n\t\tcolor: var(--iv_foreground-dim);\n\t\tfont-variant-numeric: tabular-nums;\n\t}\n</style>"}],"markdown":"/components/button.md","page":"/components/button"}