Lists, Tooltips and Toasts
Part of the drop-in UI blocks: headless rules in @reactive-agents/ui-core, thin Svelte 5 components in @reactive-agents/svelte/components, sharing @reactive-agents/svelte/styles.css, the --ra-* variables and the icons registry. The same blocks ship for React and Vue.
Lists, tooltips and toasts
Section titled “Lists, tooltips and toasts”Windowed lists, tooltips and toasts follow the same split.
Headless rules (ui-core)
Section titled “Headless rules (ui-core)”| Rule | What it gives you |
|---|---|
shouldWindow(count, threshold?) |
True when a list should be windowed (default threshold 120; shorter lists render whole) |
buildOffsets(count, heightOf) |
Prefix sums of item heights (Float64Array; offsets[count] is the total) |
computeWindow(offsets, scrollTop, viewport, overscan) |
{ start, end, padTop, padBottom, total }: the items to mount and the space standing in for the rest |
scrollDeltaForIndex(offsets, index, scrollTop, viewport, align?) |
Signed px to scroll so an item lands at "start", "center", "end" or "nearest" (0 for an index outside the list) |
resolveTip(param) |
Normalises a tooltip param (string, { text, placement?, disabled? }, or null/undefined/false) to { text, placement }, or null when nothing shows |
placeTooltip({ trigger, bubble, viewport, placement?, margin?, gap? }) |
Bubble position on "top" or "bottom": flips when it does not fit, clamps inside the viewport, returns caretX |
tipOpenDelay(now, lastHiddenAt, otherOpen) |
0 when another tooltip is open or one closed within 500 ms, else 450 ms |
createToastQueue(options?) |
A toast stack with a Svelte store contract (subscribe, get) and add, remove, removeByKey, prompt, success, error, warning, info, connection, permanent. Timers and ids are injectable, so it runs with no DOM |
addToast, removeToast, removeToastByKey |
The pure list transitions behind the queue. A toast with the same key replaces the earlier one |
TOAST_DURATIONS_MS |
Default lifetimes: success 4000, error 7000, warning 5000, info 4000, connection 5000, prompt 0 (stays until dismissed) |
A dismissed or replaced toast cancels its timer.
Svelte components
Section titled “Svelte components”<script lang="ts"> import "@reactive-agents/svelte/styles.css"; import { VirtualList, Tooltip, tooltip, Toaster, createToaster } from "@reactive-agents/svelte/components";
// Your own row type and views. Every item needs a stable `key`. import RowView from "./RowView.svelte"; import MyControl from "./MyControl.svelte"; type Row = { readonly key: string; readonly label: string };
let { rows }: { rows: Row[] } = $props(); let list: VirtualList<Row>; const toast = createToaster();</script>
<VirtualList bind:this={list} items={rows} label="Run timeline" estimate={30} overscan={8}> {#snippet item(row, index)}<RowView {row} {index} />{/snippet}</VirtualList><button onclick={() => list.scrollToIndex(120, "center")}>Jump</button>
<button use:tooltip={"Delete run"}>Delete</button><Tooltip text="Pause the run" placement="bottom"><MyControl /></Tooltip>
<Toaster toaster={toast} bottom={24} side="right" /><!-- toast.success("Saved"); toast.error("Run failed", detail, undefined, runId) -->VirtualList
Section titled “VirtualList”Mounts only what is on screen and keeps items in normal flow, so Tab order is native.
- Props:
items(each item needs a stablekey),label(the list’s accessible name),item(snippet(item, index)),estimate(px assumed until measured, default 30),overscan(default 8),threshold(lists shorter than this render whole, default 120),class. - Items are measured as they mount, so expanding rows keep the scroll height right. It follows the nearest scrolling ancestor, or the page.
- Each row announces
aria-setsizeandaria-posinset, so assistive tech hears the full count. scrollToIndex(i, align?)on a bound instance takes"start" | "center" | "end" | "nearest"(default"nearest": no move when the row is visible).- Hooks:
data-ra-virtual-list,data-ra-virtual-item.
Tooltip and use:tooltip
Section titled “Tooltip and use:tooltip”One bubble is shared and portalled to <body>, so no overflow or transform ancestor clips it. Use the action on a control; use the Tooltip wrapper (props text, placement, enabled, disabled, class, children) when the target is a component that takes no tooltip prop.
- The action takes a string,
{ text, placement?, disabled?, enabled? }, or nothing. Placement is"top"(default) or"bottom"and flips when there is no room. - Hover opens it after a short delay (at once right after another closed). Keyboard focus (
:focus-visibleonly) opens it at once. Escape, a press, scroll, resize or leaving closes it. Touch never opens it. - While open it sets
aria-describedbyon the trigger, unless the trigger’saria-labelalready carries the same text. enabledis the host’s switch (a user setting, say): a boolean, or a function read each time the tooltip would open, so a changed setting applies at once.disabledalways blocks.- Hooks:
data-ra-tooltip,data-sideon the bubble,data-ra-tooltip-triggeron the wrapper.
Toaster
Section titled “Toaster”Draws a createToaster() store: success, error, warning, info, connection, prompt (sticky, with buttons), permanent, remove and removeByKey. A later toast with the same key replaces the earlier one (one toast per run, one prompt per approval request).
- Props:
toaster(defaults to the one set withsetToaster; with neither it renders nothing),bottom(px, default 24, to clear a bottom bar),side("left"or"right", default right),dismissLabel(default"Dismiss"),icons,class. - Snippets:
icon(toast)replaces one toast’s kind icon;item(toast, { dismiss })replaces the whole card. - Errors and warnings use
role="alert"; the rest userole="status". A toast withactionshows a link that dismisses it;buttonsrunonClickand dismiss afterwards unlesscloseOnClickisfalse. - Share one toaster with a subtree through
setToaster(toaster)and read it withgetToaster(). For an app-wide toaster, export one module-level instance. - Hooks:
data-ra-toaster,data-ra-toast,data-kind.
Tokens and icons
Section titled “Tokens and icons”New --ra-* tokens for lists, tooltips and toasts: --ra-surface-pop and --ra-shadow-pop (tooltip and toast card; light and dark values), --ra-z-toast (50) and --ra-z-tooltip (60, so a tooltip stays above a toast). Icon ids used: check-circle, alert-circle, alert, info, bolt and x. The built-in set covers them, and an icons registry (prop or setIconRegistry) wins. Registry values are rendered as markup, so use static strings only.
What’s Next
Section titled “What’s Next”- Drop-in UI blocks overview: the other block pages
- Agentic UI Core: the protocol, run state and the other Svelte blocks
- Web Integration: React, Vue and Svelte bindings
Install
Bun (recommended)bun add reactive-agentsNode 22.5+npm install reactive-agentsGet notified on new releases
Release notes, about once a month.