KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Core

kt-button

GitHub Copy link

The Kanto action button. Ten variants, three sizes, an optional Lucide icon.

Preview

New entity Refresh Cancel Delete View full history Disabled
Send Send offline Export

The Kanto action button. Ten variants, three sizes, an optional Lucide icon.

<kt-button icon="plus">New entity</kt-button> <kt-button variant="secondary" icon="refresh-cw">Refresh</kt-button> <kt-button variant="danger">Delete</kt-button> <kt-button variant="text">View full history</kt-button>

Choosing a variant

VariantUse for
primaryThe one action a screen is about. At most one per view.
secondarySupporting actions. Soft indigo tint.
secondary-no-bgThe same, with no resting background — for toolbars.
darkNeutral actions that must not compete for attention.
dangerDestructive, but recoverable. Tinted red.
deleteIrreversible. The only solid red in the system — use sparingly.
warning info successStatus-carrying actions inside a matching context.
textInline, link-like. No padding, no height.

Icon-only

An icon with no slotted text collapses the button to a square. It then has no accessible name of its own, so label is required:

<kt-button icon="x" label="Close" variant="secondary-no-bg"></kt-button>

Running an action

run() takes an async action and shows how it went: busy while it runs — clicks ignored, the focus kept — then a tick, or a shake and an alert if it throws. Two seconds later the button is back at rest. done-label and failed-label replace the label meanwhile, and are announced.

<kt-button id="send" icon="send" done-label="Sent" failed-label="Not sent">Send</kt-button> <script> send.addEventListener('click', () => send.run(() => api.send(message))); </script>

It resolves with what the action resolved with and rejects with what it threw, so the caller still handles the error. A second call while one runs gets the same promise. A send plane turns into the spinner itself while it waits — its outline drawn round into a turning arc — and back into the plane, which flies off to the top right; other icons give way to a spinner, and fade. Under reduced motion only the label and icon change.

Forms

A button inside a shadow root is invisible to the enclosing form, so type="submit" would normally do nothing. <kt-button> bridges that: it runs the form's constraint validation, fires a real submit event, and carries name / value into the submission.

<form> <kt-input name="email" type="email" required></kt-input> <kt-button type="submit">Send</kt-button> </form>

API

PropertyAttributeTypeDefault
variantvariantsee table above'primary'
sizesize'small' | 'medium' | 'large''medium'
disableddisabledbooleanfalse
typetype'button' | 'submit' | 'reset''button'
iconiconstring''
iconPositionicon-position'left' | 'right''left'
labellabelstring''
fullWidthfull-widthbooleanfalse
namenamestring''
valuevaluestring''
SlotDescription
defaultThe button label
PartDescription
buttonThe native <button>
iconThe icon, when set

Emits no custom events — listen for click as on any button.