Button

Button

HkButton is the canonical button of the design system: a native <button> element with five semantic variants, four size steps, an optional leading or trailing glyph, a keyboard-shortcut chip, a busy state and an accessible name. Reach for it whenever the user triggers an action — a form's submit, a dialog's footer, a toolbar command.

  • For an icon-only trigger in a dense chrome row, use HkIconButton: the same family in a square footprint.
  • For the single floating primary action of a page, use HkFab.
  • For a dashed "add one more" affordance, use HkAddTile.

Import

tsx
1
import { HkButton } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // Button, ButtonVariant, ButtonSize
use hikari_components::prelude::*; // rsx!, VNode, Icon, MdiIcon

The Rust form is a plain function, Button(ButtonProps { … }). Inside rsx! every prop may be omitted — an omitted prop takes its default — and the component's children fill its default slot. The examples below omit the imports the page has just shown.

Variants

The variant picks the ink and the fill: primary (the default) for the one main action of a surface, secondary for companions of a primary action, outline for a quieter framed action, ghost for an action that sits inside other content, and danger for a destructive action.

Sizes

Four steps, xs / sm / md / lg; md is the default. The step sets padding, minimum height and font size; the glyph stays 16px on every step.

Glyphs, labels and shortcuts

icon and suffix put a 16px glyph before and after the caption, and shortcut renders a kbd chip at the end. A button that carries a glyph but no text collapses to the same square as an icon button. Pass label instead of a default slot when the caption should also serve as the accessible name — which it must do with collapseLabel, the breakpoint below which the visible label disappears.

In the Vue form icon and suffix are registry names (lucide export names such as "Plus"); in the Rust form they are element slots, so the example passes the crate's own Icon.

States

loading replaces the glyph with a ring, sets aria-busy and disables the button while keeping it mounted; disabled is the native disabled state; block stretches the button to the full width of its container.

Interaction

The click event carries the native MouseEvent. The example counts presses; the Rust form has no snapshot here because a snapshot is a still — it never runs an event handler. onclick is the Rust prop that receives the same event.

TSX

API

Vue

Props

NameTypeDefaultRequired
variantString as PropType<ButtonVariant>"primary"—
sizeString as PropType<ButtonSize>"md"—
loadingBooleanfalse—
disabledBooleanfalse—
blockBooleanfalse—
ariaLabelStringundefined—
shortcutStringundefined—
iconStringundefined—
suffixStringundefined—
labelStringundefined—
collapseLabelString as PropType<ButtonLabelCollapse>undefined—

Emits

EventPayload
clickMouseEvent

Rust

Props — Button

PropTypeDefaultDescription
variantButtonVariantButtonVariant::PrimarySemantic variant (hk-btn-{variant}); also the ink/fill pair.
sizeButtonSizeButtonSize::MdSize step (hk-btn-{size}).
loadingboolfalseBusy state: renders the SMIL ring, hides the prefix glyph and forces disabled (Vue: <code>disabled || loading</code>) while keeping the button mounted and aria-busy.
disabledboolfalseNative disabled (plus loading, which disables as well).
blockboolfalseFull-width presentation (hk-btn-block); also suppresses the label-collapse class (a full-width button has nothing to collapse into).
aria_labelOption<String>NoneAccessible name override; when unset the label text is used (Vue: ariaLabel ?? label).
labelOption<String>NonePlain-text label rendered in .hk-btn-label after the glyph.
collapse_labelOption<ButtonLabelCollapse>NoneBreakpoint below which the label hides and the button collapses to the icon-only square.
shortcutOption<String>NoneKeyboard shortcut hint, rendered as HKbd (size: sm) in a trailing chip.
iconOption<Element>NonePrefix glyph slot, rendered inside .hk-btn-icon and hidden while loading (Vue: the icon name prop through HIcon; see the file header delta).
suffixOption<Element>NoneSuffix glyph slot, rendered inside .hk-btn-suffix (stays visible while loading, like Vue).
childrenElement(empty)Default slot: the button body when no label text is given.
onclickOption<EventHandler<MouseEvent>>NoneClick handler (Vue: the click emit).
onmouseenterOption<EventHandler<MouseEvent>>NonePointer-enter handler on the root <button> (Vue: an onMouseenter listener reaches the root through the $attrs fallthrough).
onmouseleaveOption<EventHandler<MouseEvent>>NonePointer-leave handler on the root <button> (Vue: onMouseleave through the fallthrough).
attrsVec<(String, String)>[]Attributes set on the root <button> by name, after the component's own: title, id, form, data-*, aria-*, test hooks (Vue: the $attrs fallthrough).
classString""Extra class appended after the whole .hk-btn* family (Vue merges attrs.class last).
styleString""Host style attribute (Vue: <code>attrs.style || undefined</code> — omitted when empty).
button_typeString"button".to_string()type attribute (Vue: <code>attrs.type || "button"</code>).
autofocusboolfalseAutofocus attribute (Vue: attrs passthrough).

Accessibility

  • The button is a real <button>: it is focusable and reacts to Enter and Space. Its accessible name is the ariaLabel prop, else the label prop, else the default slot's text.
  • An icon-only button needs an explicit ariaLabel — a glyph alone names nothing.
  • While loading the button publishes aria-busy="true" and the native disabled attribute, so assistive technology announces the busy state instead of a vanishing control.
  • With collapseLabel the visible label disappears below the breakpoint but label stays the accessible name.

Related components

  • HkIconButton — the square, icon-only member of the family.
  • HkFab — the floating action button, with an optional speed dial.
  • HkAuthSubmitButton — a block button that runs the sign-in challenge lifecycle.
  • HkSupplementInset — a button surface with a hover-revealed secondary control.