Chapter 10 Feedback
Alert
A message in the page, such as a problem with the whole form or a notice about the account. The title says what it is in words; the icon's shape and the colour repeat it. For a note after an action, use a toast; for a question that needs an answer, an alert dialog.
import { AlertComponent } from '@okaapi-ui/angular';
// Not announced on page load. Shown after an action? Add role="alert" or role="status".Tones
Body text passes 7:1 on every tone, in both themes.
New: export to PDF
Reports can now be saved as PDF from the menu.Payment received
Invoice 1042 is paid.Your plan ends on 1 December
Renew it to keep your reports.The form has 2 problems
Fix the fields marked below, then send it again.<ui-alert title="New: export to PDF">Reports can now be saved as PDF from the menu.</ui-alert>
<ui-alert tone="success" title="Payment received">Invoice 1042 is paid.</ui-alert>
<ui-alert tone="warning" title="Your plan ends on 1 December">Renew it to keep your reports.</ui-alert>
<ui-alert tone="danger" title="The form has 2 problems">Fix the fields marked below.</ui-alert>With actions, and closable
Close removes it from the page; the button's name says what it does.
Your plan ends on 1 December
Renew it to keep your reports.<ui-alert
tone="warning"
title="Your plan ends on 1 December"
[dismissible]="true"
closeLabel="Dismiss"
(dismiss)="shown.set(false)"
>
Renew it to keep your reports.
<div ui-alert-actions>
<button ui-button size="sm">Renew</button>
<button ui-button size="sm" variant="secondary">See plans</button>
</div>
</ui-alert>In Arabic
الدفع وصل
الفاتورة ١٠٤٢ اتدفعت.<ui-alert tone="success" title="الدفع وصل" closeLabel="إخفاء">الفاتورة ١٠٤٢ اتدفعت.</ui-alert>When to use something else
| If you need | Use |
|---|---|
| Confirm an action that just finished | Toast |
| Stop the reader until they decide | Alert dialog |
| Show a status in a row or a card | Badge |
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
tone | 'info' | 'success' | 'warning' | 'danger' | 'info' | Icon and colour. The title must say it too. |
title | string | — | A few words in bold that say what it is. |
dismissible | boolean | false | Shows a close button. |
closeLabel | string | 'Dismiss' from labels | Its accessible name, translated. |
(dismiss) | void | — | The close button was pressed: remove the alert. |
[ui-alert-actions] | slot | — | An element holding buttons, under the message. |
Keyboard and screen readers
- The title says what it is in words; the icon and the colour only repeat it.