Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 10 Feedback

Toast

A short note after an action, such as Saved, at the bottom end of the screen. Screen readers hear it as it comes. It closes by itself after 6 seconds, but never while the pointer or focus is on it, and never when it holds an action, so nobody loses the Undo to a timer.

Use it in Angular
import { UiToast } from '@okaapi-ui/angular';

const toast = inject(UiToast);

Tones

Danger is announced at once; the others wait for the screen reader to finish.

Angular
toast.show('Address saved', { tone: 'success' });
toast.show('The card was declined. Try another card.', { tone: 'danger', title: 'Payment failed' });

With an action

It stays until it is closed or its button is pressed.

Angular
toast.show('Order 1042 deleted', {
  action: { label: 'Undo', run: () => restore(order) },
});

In Arabic

Angular
// providers: [provideUiLabels(arabicLabels)] names the region and close buttons
toast.show('العنوان اتحفظ', { tone: 'success' });

When to use something else

If you needUse
A message that must stay until it is fixedAlert
A decision the reader must make nowAlert dialog

Inputs

NameTypeDefaultWhat it does
show(message, options?)number — Shows a toast and returns its id.
options.tone'info' | 'success' | 'warning' | 'danger''info'Icon and colour. Danger is announced at once.
options.titlestring — A few words in bold before the message.
options.durationnumber6000Milliseconds; 0 keeps it. With an action it defaults to 0.
options.action{ label, run } — One button; pressing it closes the toast.
dismiss(id)void — Closes a toast.
labelssignalfrom provideUiLabelsThe region name and close button name. Set only to differ from provideUiLabels.

Keyboard and screen readers

KeysWhat they do
Tab Reach the action or the close button inside a toast.
  • Toasts sit in a named live region, so each one is read as it comes.
  • The timer waits while the pointer or focus is on a toast, and never runs on one with an action.