Fab

Fab

HkFab is the floating action button: a round, anchored trigger for the single primary action of a surface, with an optional speed dial of labelled mini-actions that fan out from it. It is positioned by CSS alone — positioning and corner pick the corner of the nearest positioned ancestor (or of the viewport), and offsetX / offsetY fine-tune the insets.

  • A page's ordinary actions belong in its toolbar or footer as Buttons; the fab is reserved for the one action that is available from anywhere on the surface.
  • An icon-only action inside a row is an HkIconButton, which is not anchored and has no dial.

Import

tsx
1
import { HkFab, type HFabAction } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // Fab, FabSize, FabCorner, FabAction, …
use hikari_components::prelude::*; // rsx!, VNode, Icon, MdiIcon

Sizes and variants

Three sizes — sm, md (the default), lg — and two inks: glass, the default translucent surface, and primary, filled with the primary colour. Each stage below is a positioned box, so the fab anchors to the stage rather than to the page.

Corners and offsets

corner is one of bottom-right (the default), bottom-left, top-right, top-left; offsetX and offsetY are CSS lengths added to the corner's inset. With positioning="fixed" the anchor is the viewport instead of the ancestor — the usual choice for an app-wide fab, not shown here because it would leave the stage.

Speed dial

With actions the main button toggles a dial: each action is a mini button with a glyph and a visible label, and expandDirection says which way they fan out (up by default). Pressing the main button emits click, then toggle with the requested open state; pressing an action runs its onClick and closes the dial. Escape and an outside pointer-down close it too. In the Vue example the dial opens when you press the button.

The Rust mirror keeps no state of its own: open is a prop the host flips from on_open_change, so the snapshot below shows the dial open.

API

Vue

Props

NameTypeDefaultRequired
iconString""—
ariaLabelString""—
positioningString as PropType<FabPositioning>"absolute"—
cornerString as PropType<FabCorner>"bottom-right"—
offsetXStringundefined—
offsetYStringundefined—
sizeString as PropType<FabSize>"md"—
variantString as PropType<FabVariant>"glass"—
disabledBooleanfalse—
actionsArray as PropType<HFabAction[]>undefined—
expandDirectionString as PropType<FabExpandDirection>"up"—
layerString as PropType<FabLayer>"host"—

Emits

EventPayload
clickMouseEvent
toggleboolean

Rust

Props — Fab

PropTypeDefaultDescription
iconOption<MdiIcon>NoneThe main glyph (Vue: a registry name string; the Rust primitive is typed).
aria_labelString""Accessible label for the main button (Vue: ariaLabel).
positioningFabPositioningFabPositioning::Absolute—
cornerFabCornerFabCorner::BottomRight—
offset_xOption<String>None--hk-fab-offset-x override (Vue: offsetX).
offset_yOption<String>None--hk-fab-offset-y override (Vue: offsetY).
sizeFabSizeFabSize::Md—
variantFabVariantFabVariant::Glass—
disabledboolfalse—
actionsOption<Vec<FabAction>>NoneSpeed-dial entries; empty = a plain round icon button.
expand_directionFabExpandDirectionFabExpandDirection::Up—
openboolfalseThe dial's open flag (Vue owns this internally; the mirror is controlled — see the header delta).
onclickOption<EventHandler<MouseEvent>>NoneFired on a main-button press (before any toggle request).
on_open_changeOption<EventHandler<bool>>NoneFired with the requested open state (main press with actions, or an action press closing the dial).
on_actionOption<EventHandler<String>>NoneFired for an activated speed-dial entry (with the entry key).

Notes

  • layer="top" floats the fab above every window through the floating layer, so its dial stays reachable while a modal or a sheet is open; the layer then owns the corner and the offsets. The Rust form has no such layer and renders in tree.
  • Always pass aria-label: the main button is icon-only. When the dial exists it also publishes aria-expanded.
  • The mini-actions are keyboard-reachable only while the dial is open, and each one is named by its label (or its key when there is no label).

Related components

  • Button — the actions that live in a toolbar or a footer.
  • HkIconButton — an icon-only action inside a row.
  • HkAddTile — a dashed in-content "add" affordance, for lists rather than pages.