BlockingToast

BlockingToast

HkBlockingToast renders the toast-shaped, flow-blocking consent prompts: a compact card in the same fixed top-end column the transient stack uses, holding a tone glyph, an optional bold title, the message, a Confirm button and a Cancel ✕. It never auto-dismisses — the flow waits for the user's answer, or for an optional timeout. It is the renderer for the gate useBlockingToast / use_blocking_toast; BlockingToastCard is the one card (Vue: HkBlockingToastCard), documented with the host that arranges it.

  • Reach for it when the answer blocks the caller — "Remove this device?", "Let this group's admins view your usage?" — and a centered modal would be too heavy.
  • A message the user can ignore is Toast; a condition that stays true for a while is PersistentToast.
  • Prompts stack: every showBlockingToast call renders its own card immediately and settles independently. A second prompt never waits for the first.

Import

tsx
1
2
3
4
5
6
7
8
import {
  HBlockingToast,
  useBlockingToast,
  showBlockingToast,
  resolveBlockingToast,
  clearBlockingToasts,
} from "@celestia-island/hikari";
import type { BlockingToastItem, BlockingToastOptions, BlockingToastVariant } from "@celestia-island/hikari";
rust
1
2
3
4
5
use hikari_components::*;          // BlockingToast, BlockingToastCard, BlockingToastItem,
                                   // BlockingToastOptions, BlockingToastVariant, BlockingToastOutcome,
                                   // BlockingToastStore, use_blocking_toast, show_blocking_toast,
                                   // resolve_blocking_toast, clear_blocking_toasts, blocking_toast_timeout_ms
use hikari_components::prelude::*; // BlockingToastProps, BlockingToastCardProps, rsx!, VNode, Callback

The Vue component is exported as HBlockingToast (not HkBlockingToast). The Rust form is BlockingToast(BlockingToastProps { … }) for the host and BlockingToastCard(BlockingToastCardProps { … }) for one card.

Asking a question: promise on Vue, callbacks on Rust

showBlockingToast(message, options) returns a Promise<boolean> on Vue: true on Confirm, false on Cancel or on timeout. The Rust gate has nothing to await, so the outcome arrives as callbacks — on_confirm, on_cancel, on_timeout on BlockingToastOptions — and the two outcomes Vue folds together are kept apart, since a timeout usually wants different copy. Pass the same handler to on_cancel and on_timeout to get Vue's shape back. resolveBlockingToast(id, true) settles a prompt programmatically; clearBlockingToasts() settles every pending prompt as cancelled.

The gate renders from a queue, so mount the host once at the shell level, next to the toast host. Every card carries role="alertdialog" and aria-label = title ?? message; the Confirm button is danger on the danger card and primary on the other two, always small; the Cancel is the house ghost ✕ at size 24 whose accessible name is the resolved cancel label, and the button order is primary first (left), dismiss second (right) — the same order as the other confirmation surfaces.

Decision: pending

Both cards ask the same question. The TSX one is live: press Remove or Keep device and the line under it flips to removed or kept; leave it for 30 seconds and it flips to kept — a timeout resolves false, the same value a cancel produces. The Rust card is a still: the danger tone, the Alert glyph, Remove in the danger button and Keep device as the ✕'s name; pressing it in a sample settles nothing, because the docs page mounts no store.

Tones, labels and the Rust seams

Three tones: info (the default, "Confirm"), warning (an AlertTriangle glyph) and danger (the destructive one). Every label falls back to i18n — hikari::blockingToast.confirm / hikari::blockingToast.cancel — so a card with no confirmLabel / cancelLabel still reads in the user's language; the cancel text lives only in the ✕'s accessible name (aria-label + title), never as visible text.

Rust deltas, declared in the source. The Rust confirm button emits the hk-btn* contract directly (hk-btn hk-btn-primary hk-btn-sm) instead of riding the Vue HButton, whose Rust twin is still the legacy button; the container is rendered in place with no per-card inline z-index (the sheet's band orders the cards, newest last); transitions and leave-geometry pinning are not reproduced; and the danger glyph is MdiIcon::Alert because lucide's XCircle has no packed MDI twin.

Rust gap. BlockingToast takes its props as items (Option<Vec<BlockingToastItem>>, None renders the shared queue) — there is no prop through which a docs page can show the cards it has not queued, and BlockingToast { items: … } inside a fence does not build: error[E0422]: cannot find struct, variant or union type 'BlockingToastProps' in this scope. BlockingToastOptions also carries on_confirm / on_cancel / on_timeout where Vue's options carry only data, so build cards with BlockingToastItem directly; timeout_ms: blocking_toast_timeout_ms(Some(n)) is the same normalisation the store applies (Some(0) means "no timeout").

Rust
Attack blocked

snowfox tried to take 14 damage; 6 absorbed by the ward.

A warning card on the same surface: the triangle glyph, a title line, the message, and Retaliate as the confirm label. cancel_label is left empty, so the ✕ is named by the i18n default "Cancel" — the fallback path, not a missing name.

API

Vue

Rust

Props — BlockingToast

PropTypeDefaultDescription
itemsOption<Vec<BlockingToastItem>>NoneRender exactly these cards instead of the shared queue (keeps the card layer usable standalone / in tests).
classString""—

Props — BlockingToastCard

PropTypeDefaultDescription
itemBlockingToastItemDefault::default()—
on_resolveOption<Callback<bool>>NoneFired with true on confirm and false on cancel (Vue: the confirm / cancel emits).

Accessibility

  • The card is role="alertdialog" with aria-label = title ?? message, so an announcement names the question rather than reading the raw body.
  • Distinct from a modal: there is no focus trap, no scroll lock and no initial focus — the user keeps working elsewhere while the prompt waits. The card is reached by the normal Tab order, and it is not a live region, so a queued prompt is not re-announced on every unrelated update.
  • The Confirm button's visible text is its name. The Cancel control is an icon button whose aria-label and title are the resolved cancel label, so "Keep device" is heard even though the button shows only an ✕.
  • Order encodes meaning twice: the glyph names the tone, and the primary/dismiss order (confirm left, cancel right) is the house convention across confirmation surfaces.
  • The timeout is silent to assistive technology: nothing announces that a prompt will expire. If the deadline matters, say it in the message.

Related components

  • Toast — the transient stack these cards sit beside.
  • IconButton — the ghost ✕ seat the cancel rides.
  • Button — the button family whose spacing and label spans the confirm clones.
  • PersistentToast — a chip that stays while a condition holds, instead of asking once.