Toast
HkToast renders the transient corner stack: one card per type in the fixed top-end column, each card showing one message (the most recent one that has finished swapping in), a per-type glyph, an optional "N msgs" counter, an optional inline action button, an optional copy button and a close ✕. It is the renderer for the store useToast() / use_toast(); the store decides what is stacked, the card only draws it.
- Reach for it when a page needs to say something and keep working — "Saved", "Upload failed". Push through the store (toast.success("…")), never by mounting cards by hand: the store owns the per-type slot, the durations, the message cap and the timers.
- A prompt that must be answered before the flow continues is BlockingToast — it never auto-dismisses.
- A status chip that lives in a chrome bar beside a condition (a load in flight, an upstream outage) is PersistentToast; a row of those with overflow is PersistentToastGroup.
Import
;
from "@celestia-island/hikari";
use *; // Toast, ToastItemView, use_toast, ToastStore, ToastType,
// ToastSlot, ToastMessage, ToastAction, ToastOptions,
// toast_count_label, toast_auto_dismiss_ms
use *; // ToastProps, ToastItemViewProps, rsx!, VNode, Callback, Signal
The Vue component is exported as HToast; HkToast (and HkToastItem) are not in the root barrel, so import { HkToast } from "@celestia-island/hikari" fails to resolve — use HToast. Its props are teleport, defaulting to true. The Rust form is Toast(ToastProps { … }).
One slot per type, and how messages land in it
Pushes aggregate by type: error, success, warning, info, loading — at most one slot each, in first-push order. Every further push of the same type appends to that slot's message list, up to MAX_TOASTS_PER_SLOT (5); past that the oldest message is dropped. An identical text pushed twice in a row is a duplicate: it replaces the previous entry instead of appending, reusing its id, and restarts the dismiss clock. The card shows count > 1 as an "N msgs" counter while the body still shows one message at a time — the newest, once its swap window has closed (see below).
Slots: 0
The TSX card seeds three slots on mount — a green success, a blue info and a red error — each with its own glyph and its own clock. The Rust card is a still frame: nothing is pushed, so the stack is the empty column. The store API on that side is use_toast(), a copyable ToastStore handle with success, error, show, push, loading, remove and slots.
The action button, the copy button and the close ✕
An inline action (action.label + action.onClick, today "Undo" after a delete) is owned by the latest push: every push sets or clears it, so a plain message removes the button from the shared slot. The action is single-shot and the card is dismissed first, the handler runs second — a throwing handler cannot keep a dismissed toast on screen. copyable is a monotonic upgrade (an explicit true turns it on for the whole slot and it never turns off) and defaults to true for error / warning only; the copy payload is every stacked message joined by a blank line. The ✕ always removes the slot.
The Rust host supplies the clipboard sink itself: Toast { on_copy } is a Callback<String> receiving that joined text, because the crate exposes no clipboard op. Inside ToastItemView the same seam is on_copy.
One slot, two messages, the newest displayed, the counter reading "2 msgs". The card carries the inline action, the copy button and the ✕ — three controls in one row. Pressing them in a sample cannot act: no store is mounted behind a docs page.
Timing, rotation and the Rust deltas
Each type has a default duration: error / warning 30 s, success / info 3 s, loading never (0); a per-call duration overrides it and 0 means "wait for the ✕". The clock restarts on every push to the slot. When several messages are stacked, the body swaps out-in to the newest one (a ~150 ms window) — the card you see in a snapshot is a single frame of that rotation, never the animation.
Rust deltas, declared in the source. The store is a thread-local shared by every Toast host, so two mounted hosts render the same stack; the sheet's hk-toast-enter/leave/move transition classes and leave-geometry pinning are not reproduced (a removed slot is gone on the next render); the container is rendered in place — position: fixed does the work — and loses the overlay root's stacking fence; error uses MdiIcon::Alert and success MdiIcon::Check because lucide's XCircle / CheckCircle have no packed MDI twin.
Numeric literals. The examples spell durations without digit separators (Some(30000)), matching how the type defaults read (30 s for error / warning, 3 s for success / info). That is style, not a limit — grouped literals such as Some(30_000) are ordinary Rust and build fine.
Rust gap. Toast / ToastItemView take no icon prop in Rust: ToastItemViewProps is slot, displayed, on_remove, on_copy. Passing icon: … inside an rsx! block fails with error[E0560]: struct 'hikari_components::ToastItemViewProps' has no field named 'icon'. Rendering Toast itself does build — it mounts the thread-local store's container and prints whatever the store already holds (Toast {} renders an empty div.hk-toast-container), which is the honest snapshot of a host that has not pushed anything yet.
Slots: 0
The TSX card mounts the stack with teleport: false, the face for host shells that own their stacking context — where the teleported band would be painted over by the shell's own backdrop. The Rust card is the single-message shape: one warning, copy button, no counter, no action.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| teleport | Boolean | true | — |
Rust
Props — Toast
| Prop | Type | Default | Description |
|---|---|---|---|
| on_copy | Option<Callback<String>> | None | Copy sink for the per-item copy button: receives the slot's messages joined by a blank line (Vue: the item's own useClipboard()). |
| class | String | "" | — |
Props — ToastItemView
| Prop | Type | Default | Description |
|---|---|---|---|
| slot | ToastSlot | Default::default() | The aggregated slot (Vue: the item's toast prop). |
| displayed | Option<ToastMessage> | None | The message the rotation gate displays (Vue: displayedMessage); None renders empty text. |
| on_remove | Option<Callback<u64>> | None | Fired with the slot id when the ✕ or the inline action dismisses it (Vue: the remove emit). |
| on_copy | Option<Callback<String>> | None | Fired with the joined text when the copy button is clicked. |
Accessibility
- Each card is its own live region: role="alert" + aria-live="assertive" for error, role="status" + aria-live="polite" for every other type. Errors therefore interrupt a screen reader, the rest queue behind whatever it is saying.
- The counter ("2 msgs") is plain text inside the live region, so it is announced with the message it sits beside — not as a separate update.
- The copy and close controls are real buttons with accessible names from the i18n strings hikari::toast.copy / hikari::toast.close (and title for the hover hint); the inline action's visible label is its name — Vue adds no title on purpose, so the tooltip never repeats the button.
- The message span carries title = the full text, the one hover affordance for a message clamped to three lines.
- The stack is a fixed column with no landmark role and nothing focusable of its own except the per-card buttons; a toast never takes focus, so a keyboard user reaches its buttons only by tabbing into the corner.
Related components
- BlockingToast — the toast-shaped prompt that waits for an answer.
- PersistentToast — the chrome-bar chip that stays while a condition holds.
- PersistentToastGroup — a row of those chips with a "+N" overflow.
- IconButton — the copy / close seats the card rides.