Toast
Bounded transient feedback; essential errors remain persistently available elsewhere.
Use the web element directly without the semantic runtime.
A registered presentation adapter can bind this component to host-owned meaning and state.
The standard recipe resolver does not select this component automatically.
Import and live example#
One persistent success toast with an explicit dismiss button.
Interactive preview requires JavaScript.
View the complete example source
import {registerAeliqoElements} from "@varendo/web";
import {
AeliqoAlertElement,
AeliqoDialogElement,
AeliqoDrawerElement,
AeliqoEmptyStateElement,
AeliqoPopoverElement,
AeliqoProgressElement,
AeliqoSkeletonElement,
AeliqoToastElement,
AeliqoTooltipElement,
} from "@varendo/web/feedback";
registerAeliqoElements();
const host = document.querySelector<HTMLElement>("#aeliqo-example") ?? (() => {
const created = document.createElement("div");
created.id = "aeliqo-example";
(document.body ?? document.documentElement).append(created);
return created;
})();
function createCatalogRoot(container: HTMLElement): HTMLElement {
const root = document.createElement("div");
root.dataset.catalogSourceRoot = "true";
root.style.display = "grid";
root.style.gap = "12px";
container.append(root);
return root;
}
function createCatalogElement<T extends HTMLElement>(tagName: string, container: HTMLElement): T {
const element = document.createElement(tagName) as T;
element.setAttribute("data-aeliqo-theme", "light");
container.append(element);
return element;
}
function appendSlottedText(root: HTMLElement, slot: string, textContent: string): void {
const content = document.createElement("span");
content.slot = slot;
content.textContent = textContent;
root.append(content);
}
const root = createCatalogRoot(host);
(((root) => {
const element = createCatalogElement<AeliqoToastElement>("aeliqo-toast", root);
element.message = "Report saved";
element.tone = "success";
element.open = true;
element.duration = 0;
element.dismissible = true;
}))(root);
Purpose#
Transient feedback shown while open. Non-danger tones can dismiss on a timer or by request; danger
tones remain open until dismissed. Keep important failures available in a persistent place too.
When to use it#
- Confirming an action that already finished, such as a save.
- The feedback is brief and can disappear without loss.
- Anything important also lives in a persistent place.
When to use a different component#
- Use Alert for a message that must stay in the reading flow.
- Use EmptyState when a region needs a lasting explanation.
Properties and defaults#
Keep essential information outside transient notifications; duration zero makes this fixture reviewable.
| Property | Use and ownership | Declared type | Initial value |
|---|---|---|---|
open | Controls whether the overlay or expandable surface is currently open. | boolean | false |
message | Provides the user-facing status, error, or recovery message. | string | '' |
tone | Selects a semantic visual tone such as neutral, informative, success, warning, or danger. | AeliqoFeedbackTone | 'info' |
duration | Sets the visible toast duration in milliseconds. Use a persistent alert for information that must be acknowledged. | number | 5000 |
dismissible | Shows a user dismissal control. The host still removes or updates the message after the event. | boolean | true |
Events#
| Event | Payload | Emitted | Application responsibility |
|---|---|---|---|
aeliqo-toast-dismiss | The dismissal reason for the current toast. | After timeout or user dismissal. | Remove the toast from application state. |
Events cross the component boundary as user proposals. Validate their detail and current authority before applying a business effect.
Listen for aeliqo-toast-dismiss
const element = document.querySelector('aeliqo-toast');<p>element?.addEventListener('aeliqo-toast-dismiss', (event) => {
const proposal = (event as CustomEvent<unknown>).detail;
// Validate the proposal, update host state, then assign controlled properties.
applyProposal(proposal);
});States and failure handling#
Relevant states:
- ready
Expected result: The status is announced as transient feedback and can be dismissed by the user.
Set duration to zero for a notification that remains visible until the host
or user dismisses it. Timed notifications are capped at 60 seconds; a
danger tone never dismisses on the timer. Keep a durable status or error
elsewhere if a user may need to read or act on it after the toast closes.
Keyboard, focus, and accessibility#
Keyboard behavior:
- Tab to dismiss
- Enter or Space
- Escape where host handles it
Exposed semantics:
- aria-label
- aria-live
- button
- role
Responsive behavior#
Allow long messages to wrap within the available width. Place transient feedback where it does not cover fixed task controls.
Style hooks#
- Shadow parts:
close,message,toast - Varendo design tokens referenced:
--aeliqo-color-info,--aeliqo-color-surface,--aeliqo-control-min-target,--aeliqo-elevation-raised,--aeliqo-radius-medium,--aeliqo-space-12,--aeliqo-space-16
Related components#
Generated TypeScript declaration#
View generated declaration
export declare class AeliqoToastElement extends AeliqoFoundationElement {
static readonly properties: {
open: {
type: BooleanConstructor;
reflect: boolean;
};
message: {
type: StringConstructor;
};
tone: {
type: StringConstructor;
};
duration: {
type: NumberConstructor;
};
dismissible: {
type: BooleanConstructor;
};
};
static readonly styles: import("lit").CSSResult[];
open: boolean;
message: string;
tone: AeliqoFeedbackTone;
duration: number;
dismissible: boolean;
private timer;
protected updated(changed: Map<string, unknown>): void;
disconnectedCallback(): void;
private dismiss;
protected render(): import("lit").TemplateResult<1>;
}Version#
This page documents the Varendo 0.6 component contract.
