Navigation

Button

<oblyx-button> renders a native <button>, or an <a> when href is set. It carries its own visual style, size, elevation, disabled and loading states as plain attributes, and participates in native form submission the same way a hand-written <button> would.

Basic button

Save
HTMLKotlin
<oblyx-button>Save</oblyx-button>
oblyxButton { +"Save" }

Variants

Four visual styles. secondary is the default; use primary for the one dominant action on a screen and destructive for actions that delete or revoke something.

Button variants

Save Save Save Delete account
HTMLKotlin
<oblyx-button variant="primary">Save</oblyx-button>
<oblyx-button variant="secondary">Save</oblyx-button>
<oblyx-button variant="ghost">Save</oblyx-button>
<oblyx-button variant="destructive">Delete account</oblyx-button>
oblyxButton(variant = OblyxButtonVariant.PRIMARY) { +"Save" }
oblyxButton(variant = OblyxButtonVariant.SECONDARY) { +"Save" }
oblyxButton(variant = OblyxButtonVariant.GHOST) { +"Save" }
oblyxButton(variant = OblyxButtonVariant.DESTRUCTIVE) { +"Delete account" }

Sizes

Button sizes

Small Medium Large
HTMLKotlin
<oblyx-button size="sm">Small</oblyx-button>
<oblyx-button size="md">Medium</oblyx-button>
<oblyx-button size="lg">Large</oblyx-button>
oblyxButton(size = OblyxButtonSize.SM) { +"Small" }
oblyxButton(size = OblyxButtonSize.MD) { +"Medium" }
oblyxButton(size = OblyxButtonSize.LG) { +"Large" }

Elevation

A resting shadow depth for a button that floats above the page, such as a mobile action button. Most buttons in normal document flow stay at the default, none.

Button elevation

None Low Med High
HTMLKotlin
<oblyx-button elevation="none">None</oblyx-button>
<oblyx-button elevation="low">Low</oblyx-button>
<oblyx-button elevation="med">Med</oblyx-button>
<oblyx-button elevation="high">High</oblyx-button>
oblyxButton(elevation = OblyxButtonElevation.NONE) { +"None" }
oblyxButton(elevation = OblyxButtonElevation.LOW) { +"Low" }
oblyxButton(elevation = OblyxButtonElevation.MED) { +"Med" }
oblyxButton(elevation = OblyxButtonElevation.HIGH) { +"High" }

Disabled and loading

disabled blocks interaction and native form submission, the same as a plain <button disabled>. loading shows a spinner in place of the visible content and sets aria-busy; by default it also blocks interaction, so pass label alongside it. The button's visible content is hidden from assistive tech while loading, and label is what re-asserts its accessible name in that state.

Disabled

Save
HTMLKotlin
<oblyx-button disabled>Save</oblyx-button>
oblyxButton(disabled = true) { +"Save" }

Loading

Save
HTMLKotlin
<oblyx-button loading label="Save">Save</oblyx-button>
oblyxButton(loading = true, label = "Save") { +"Save" }

Set interruptible to keep a loading button clickable: the spinner and aria-busy still apply, but the button stays interactive. Use this for actions a user can reasonably cancel or repeat mid-flight, not for a fire-once submit, save, or pay button.

Interruptible loading

Uploading
HTMLKotlin
<oblyx-button loading interruptible label="Uploading">Uploading</oblyx-button>
oblyxButton(loading = true, interruptible = true, label = "Uploading") { +"Uploading" }

Icon-only buttons

Set icon-only for a square, icon-only button. There is no icon attribute and no slot to distinguish icon content from labeled content: the button's content is whatever markup the caller puts inside it, icon included, so icon-only declares intent explicitly, and label is required as the sole accessible name. Omitting label on an icon-only button logs a console error rather than rendering silently wrong.

Icon-only button

HTMLKotlin
<oblyx-button icon-only label="Close">
  <oblyx-icon name="close"></oblyx-icon>
</oblyx-button>
oblyxButton(iconOnly = true, label = "Close") {
  oblyxIcon(name = OblyxIconName.CLOSE)
}

Link buttons

Setting href renders an <a> styled as a button instead of a <button>. This only happens while the button is interactive: a disabled or non-interruptible-loading button always renders as a real <button>, even with href set, because a disabled link is an accessibility anti-pattern and neither state can be represented on an <a>.

Link button

Read the docs
HTMLKotlin
<oblyx-button href="/docs/" variant="secondary">Read the docs</oblyx-button>
oblyxButton(href = "/docs/", variant = OblyxButtonVariant.SECONDARY) { +"Read the docs" }

Disabled link button renders as a button

href is set here too, but disabled forces the <button> path.

Read the docs
HTMLKotlin
<oblyx-button href="/docs/" disabled>Read the docs</oblyx-button>
oblyxButton(href = "/docs/", disabled = true) { +"Read the docs" }

Type and form submission

Oblyx does not port Astryx's default of overriding type to "button". Leave type unset and <oblyx-button> renders no type attribute on its inner <button> at all, so the browser's own default applies: inside a <form>, that default is submit. A button you meant as a plain action button, placed inside a form with no explicit type, will submit that form. This is standard native <button> behavior, not an Oblyx quirk, but it surprises anyone coming from Astryx or another library that changed the default.

Unset type submits the form

No type attribute here. Click Save and the form submits.

Save
HTMLKotlin
<form onsubmit="event.preventDefault(); this.querySelector('output').textContent = 'Form submitted.';">
  <oblyx-button>Save</oblyx-button>
  <output></output>
</form>
form {
  oblyxButton { +"Save" }
}

Pass type="button" explicitly on anything that must not submit, the same way you would on a plain HTML button.

Explicit type opts out of submission

Click Cancel and the form does not submit.

Cancel
HTMLKotlin
<form onsubmit="event.preventDefault(); this.querySelector('output').textContent = 'Form submitted.';">
  <oblyx-button type="button">Cancel</oblyx-button>
  <output></output>
</form>
form {
  oblyxButton(type = OblyxButtonType.BUTTON) { +"Cancel" }
}

Reference

<oblyx-button>

AttributeTypeDefaultDescription
typebuttonsubmitresetHTML type attribute of the inner <button>. Unset by default. Meaningless (and never rendered) on the <a> path.
namestring | undefinedHTML name attribute, passed straight through for form submission.
valuestring | undefinedHTML value attribute, passed straight through for form submission.
formstring | undefinedAssociates the button with a <form> by id, passed straight through.
variantprimarysecondaryghostdestructivesecondaryVisual style.
sizesmmdlgmdSize.
elevationnonelowmedhighnoneResting shadow depth for a floating button.
disabledbooleanfalseNative disabled state. Reflected as a real boolean attribute so <oblyx-button disabled> reads the way plain HTML would.
loadingbooleanfalseLoading state. Shows a spinner and sets aria-busy while active.
interruptiblebooleanfalseKeep the button interactive while loading: the loading visuals and aria-busy still apply, but the button is not disabled. Use for interruptible actions, not fire-once submit/save/pay buttons.
icon-onlybooleanfalseSquare, icon-only rendering. Requires label to carry the accessible name, since there is no visible text left to provide one.
labelstring | undefinedAccessible name. Required when iconOnly is set, since nothing visible provides one otherwise. Also used, while loading, to re-assert the button's purpose as its accessible name once the visible content is hidden from assistive tech. Optional otherwise: plain visible text content already provides an accessible name natively.
hrefstring | undefinedRenders an <a href> instead of a <button>.
targetstring | undefinedHTML target, only meaningful with href.
relstring | undefinedHTML rel, only meaningful with href.