IconButton

IconButton

HkIconButton is the square, icon-only trigger every chrome row uses: toolbars, page headers, list rows, dialog headers. It comes in six box sizes from 16px to 40px and five inks, and it can carry a status dot of its own.

  • Several related icon buttons that act as one control — a view switcher, a toggle set, a tight toolbar — belong in an HkIconButtonGroup, which adds the tooltip and the shared track.
  • A text button that happens to hold only a glyph collapses to the same square; keep it a Button when a caption may return.

Import

tsx
1
import { HkIconButton } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // IconButton, IconButtonVariant, IconButtonSize
use hikari_components::prelude::*; // rsx!, VNode, Icon, MdiIcon

Variants

The variant is the ink: ghost (the default) draws only the glyph, primary, secondary, danger and success fill the square. An icon button always needs an accessible name — pass aria-label.

Sizes

Six box steps in pixels: 16, 24, 28, 32 (the default), 36 and 40. The 28px step matches the header chrome; the glyph grows with the box. In the Vue form icon is a registry name (a lucide export name such as "Search"); in the Rust form it is a typed MdiIcon.

Status dot, title and disabled state

dot draws a small status mark inside the button's own box, in the bottom-right corner; dotVariant picks its tone. The dot is decoration unless dotLabel names it. A native title adds a tooltip on hover — it is not an accessible name, so it complements aria-label rather than replacing it. In the Rust form title is an explicit prop; in the Vue form the component's declared props do not list it, which is why the TSX example leaves it out.

A glyph of your own

The default slot wins over the icon prop, so any renderable glyph can sit in the square — a custom SVG, an image component, an icon of another set.

Interaction

click carries the native MouseEvent. The example is a mute toggle: the glyph, the ink and the accessible name all follow one piece of state.

TSX

API

Vue

Props

NameTypeDefaultRequired
iconString""—
variant<code>String as PropType<"ghost" | "primary" | "secondary" | "danger" | "success"></code>"ghost"—
size<code>Number as PropType<16 | 24 | 28 | 32 | 36 | 40></code>32—
disabledBooleanfalse—
dotBooleanfalse—
dotVariantString as PropType<CornerBadgeVariant>"success"—
dotLabelStringundefined—

Emits

EventPayload
clickMouseEvent

Rust

Props — IconButton

PropTypeDefaultDescription
iconOption<MdiIcon>NoneThe glyph (Rust: a typed MDI icon — Vue passes a name string through HIcon).
variantIconButtonVariantIconButtonVariant::GhostInk (hk-icon-button-{variant}).
sizeIconButtonSizeIconButtonSize::S32Box step (hk-icon-button-{size}).
disabledboolfalseNative disabled.
dotboolfalseButton-owned status dot (.hk-icon-button-dot), laid out INSIDE the button's own box so the mark and the control read as one silhouette.
dot_variantIconButtonDotVariantIconButtonDotVariant::SuccessTone of the status dot.
dot_labelOption<String>NoneAccessible name for the dot.
aria_labelOption<String>NoneAccessible name for the button itself (Vue: attrs['aria-label']).
titleOption<String>NoneNative title (Vue: attrs.title).
aria_expandedOption<bool>NoneDisclosure state (Vue: attrs['aria-expanded']).
aria_describedbyOption<String>Noneid of the element describing this button (Vue: attrs['aria-describedby']).
icon_slotOption<Element>NoneNamed icon slot: wins over the default slot and the icon prop (Vue: slots.icon).
childrenElement(empty)Default slot: a natural <HIconButton><Icon/></HIconButton> composition.
onclickOption<EventHandler<MouseEvent>>NoneClick handler (Vue: the click emit).
classString""Extra class appended after the size/variant classes.
styleString""Host style attribute; omitted when empty.
button_typeOption<String>Nonetype attribute passthrough.
autofocusboolfalseAutofocus attribute (Vue: attrs passthrough).

Accessibility

  • Always pass aria-label: a glyph alone names nothing, and a title tooltip does not count as an accessible name.
  • The button is a real <button> with type="button" by default, so it never submits a surrounding form by accident.
  • The status dot is aria-hidden decoration unless dotLabel gives it a name; describe the state the dot stands for in that label.
  • Attributes such as aria-expanded and aria-describedby fall through to the button element; in the Rust form they are explicit props.

Related components