Message
A message is a short, light notice that appears at the top of the page after an action ("Saved", "Upload failed", "Loading…") and goes away by itself. It takes no focus and does not stop the user. You open it with a call from code, from anywhere, not by writing an element in a template.
When to use
- Use it to give feedback on an action: a success, an error, a warning, or work that is in progress.
- A message is for short feedback that does not block anything. A decision the user must make needs a dialog, and a longer text with a title a notification (both are planned).
- A message goes away by itself, so do not put information in it that the user must be able to find again.
Examples
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
</script>
<!-- A call from anywhere in the code: no setup, no markup. The library makes a layer on the page by itself. -->
<Button onclick={() => message.info('This is a normal message')}>Show message</Button>
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
</script>
<!-- Five kinds. error and warning are read out at once by a screen reader; the others wait for it to finish. -->
<div class="row">
<Button onclick={() => message.info('This is an information message')}>info</Button>
<Button onclick={() => message.success('This is a success message')}>success</Button>
<Button onclick={() => message.error('This is an error message')}>error</Button>
<Button onclick={() => message.warning('This is a warning message')}>warning</Button>
<Button onclick={() => message.loading('Action in progress..')}>loading</Button>
</div>
<style>
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
</style>
duration 1 (seconds; the default is 3)
duration 6
duration 0: until it is closed from code
<script lang="ts">
import { Button, message, type MessageHandle } from 'svelte-ant-design';
// The function that a call returns closes the message.
let hide: MessageHandle | undefined;
</script>
<div class="stack">
<div class="field">
<span class="caption">duration 1 (seconds; the default is 3)</span>
<Button onclick={() => message.info('Gone in a second', 1)}>1 second</Button>
</div>
<div class="field">
<span class="caption">duration 6</span>
<Button onclick={() => message.info('Stays for six seconds', 6)}>6 seconds</Button>
</div>
<div class="field">
<span class="caption">duration 0: until it is closed from code</span>
<div class="row">
<Button onclick={() => (hide = message.loading('Stays until you close it', 0))}>Open</Button>
<Button onclick={() => hide?.()}>Close it</Button>
</div>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.caption {
color: var(--ads-color-text-secondary);
font-size: 12px;
}
</style>
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
// The same key updates the message in place: the box stays where it is, and a screen reader reads the new text.
function run() {
message.loading({ content: 'Loading...', key: 'updatable', duration: 0 });
setTimeout(() => message.success({ content: 'Loaded!', key: 'updatable', duration: 2 }), 1500);
}
</script>
<Button onclick={run}>Load</Button>
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
// The handle is thenable: the promise resolves when the message starts to close, so the next one comes in as
// the first one goes. (For the same reason `await message.info(...)` waits for the message to close.)
function run() {
message
.loading('Action in progress..', 2.5)
.then(() => message.success('Loading finished', 2.5))
.then(() => message.info('Loading finished is finished', 2.5));
}
</script>
<Button onclick={run}>Display sequential messages</Button>
content: string, number, snippet
content: a snippet with a button Undo pressed 0 times
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
let undone = $state(0);
</script>
<!-- A snippet can hold a link or a button. It is drawn in the layer, so it sees the context of the place where the
MessageHost is, not of this component. -->
{#snippet saved()}
Saved
<Button size="small" type="link" onclick={() => undone++}>Undo</Button>
{/snippet}
<div class="stack">
<div class="field">
<span class="caption">content: string, number, snippet</span>
<div class="row">
<Button onclick={() => message.info('A string')}>string</Button>
<Button onclick={() => message.info(0)}>number 0</Button>
</div>
</div>
<div class="field">
<span class="caption">content: a snippet with a button</span>
<Button onclick={() => message.success({ content: saved, duration: 6 })}>snippet</Button>
<span role="status">Undo pressed {undone} times</span>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.caption {
color: var(--ads-color-text-secondary);
font-size: 12px;
}
</style>
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
</script>
<!-- A string is shown as text (an emoji, for example), a snippet is drawn as it is, false removes the icon. -->
{#snippet star()}
<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">
<path d="M8 1l2.1 4.6 5 .5-3.8 3.4 1.1 4.9L8 11.8 3.6 14.4l1.1-4.9L.9 6.1l5-.5z" />
</svg>
{/snippet}
<div class="row">
<Button onclick={() => message.info({ content: 'A string icon', icon: '🎉' })}>string</Button>
<Button onclick={() => message.warning({ content: 'A snippet icon', icon: star })}>snippet</Button>
<Button onclick={() => message.success({ content: 'No icon', icon: false })}>false</Button>
</div>
<style>
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
</style>
class, style: on the box
classNames, styles: the parts (root, wrapper, icon, title, close)
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
</script>
<div class="stack">
<div class="field">
<span class="caption">class, style: on the box</span>
<Button
onclick={() => message.info({ content: 'Styled box', class: 'fancy', style: { 'border-radius': '24px' } })}
>
class and style
</Button>
</div>
<div class="field">
<span class="caption">classNames, styles: the parts (root, wrapper, icon, title, close)</span>
<Button
onclick={() =>
message.success({
content: 'Styled parts',
closable: true,
classNames: { title: 'fancy-title' },
styles: { root: { background: 'var(--ads-color-primary-solid)', color: '#fff' }, icon: { color: '#fff' }, close: { color: '#fff' } }
})}
>
classNames and styles
</Button>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.caption {
color: var(--ads-color-text-secondary);
font-size: 12px;
}
/* The message is drawn outside this component, so a class that styles it is global here. */
:global(.fancy) {
outline: 2px dashed var(--ads-color-primary);
}
:global(.fancy-title) {
font-weight: 600;
letter-spacing: 0.02em;
}
</style>
pauseOnHover (the default), duration 3: keep the pointer over it
pauseOnHover: false
closable, duration 3: Tab into it, and it waits for you
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
</script>
<!-- Hover (a mouse or a pen, not a touch) and focus inside the message stop the timer; it goes on with the time that
was left. The timer also waits while the page is hidden. -->
<div class="stack">
<div class="field">
<span class="caption">pauseOnHover (the default), duration 3: keep the pointer over it</span>
<Button onclick={() => message.info('Hover me: I stay while you do')}>pauses</Button>
</div>
<div class="field">
<span class="caption">pauseOnHover: false</span>
<Button onclick={() => message.info({ content: 'I go on, whatever you do', pauseOnHover: false })}>does not pause</Button>
</div>
<div class="field">
<span class="caption">closable, duration 3: Tab into it, and it waits for you</span>
<Button onclick={() => message.warning({ content: 'Focus inside holds the timer', closable: true })}>holds on focus</Button>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.caption {
color: var(--ads-color-text-secondary);
font-size: 12px;
}
</style>
clicked 0, closed 0
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
let clicks = $state(0);
let closes = $state(0);
</script>
<!-- onclick is for a mouse or a finger only: a box cannot be reached with the keyboard. Put a button in the content
(see Content) for an action. onclose is called once, when the message starts to close, however it was closed. -->
<div class="field">
<Button onclick={() => message.info({ content: 'Click me', onclick: () => clicks++, onclose: () => closes++ })}>Open</Button>
<span role="status">clicked {clicks}, closed {closes}</span>
</div>
<style>
.field {
display: grid;
justify-items: start;
gap: 8px;
}
</style>
closable, duration 0: stays until the button is pressed
closable, duration 3
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
</script>
<!-- closable adds a button. Enter and Space press it, and Escape closes the message that has focus inside it. -->
<div class="stack">
<div class="field">
<span class="caption">closable, duration 0: stays until the button is pressed</span>
<Button onclick={() => message.info({ content: 'A message that stays', closable: true, duration: 0 })}>stays</Button>
</div>
<div class="field">
<span class="caption">closable, duration 3</span>
<Button onclick={() => message.error({ content: 'Upload failed', closable: true })}>can be closed</Button>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.caption {
color: var(--ads-color-text-secondary);
font-size: 12px;
}
</style>
maxCount not set
<script lang="ts">
import { Button, Switch, message } from 'svelte-ant-design';
let limited = $state(false);
let opened = $state(0);
// maxCount is a setting of message.config(); undefined takes it back to the default.
$effect(() => {
message.config({ maxCount: limited ? 3 : undefined });
return () => message.config({ maxCount: undefined });
});
</script>
<div class="stack">
<div class="row">
<Switch bind:checked={limited} aria-label="maxCount 3" />
<span>maxCount {limited ? 3 : 'not set'}</span>
</div>
<div class="field">
<div class="row">
<Button onclick={() => message.info({ content: `Message ${++opened}`, duration: 0 })}>Open one</Button>
<Button onclick={() => message.destroy()}>Close all</Button>
</div>
<span role="status">The oldest closes to make room: {opened} opened</span>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
</style>
top: 8 (px)
<script lang="ts">
import { Button, message } from 'svelte-ant-design';
let top = $state<number | string>(8);
$effect(() => {
message.config({ top });
return () => message.config({ top: undefined });
});
</script>
<!-- top is a number (pixels) or any CSS length. -->
<div class="stack">
<div class="field">
<span class="caption">top: {typeof top === 'number' ? `${top} (px)` : `'${top}'`}</span>
<div class="row">
<Button onclick={() => (top = 8)}>8</Button>
<Button onclick={() => (top = 80)}>80</Button>
<Button onclick={() => (top = '30vh')}>'30vh'</Button>
</div>
</div>
<Button onclick={() => message.info({ content: 'Where am I?', duration: 5 })}>Show message</Button>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.caption {
color: var(--ads-color-text-secondary);
font-size: 12px;
}
</style>
stack off
<script lang="ts">
import { Button, Switch, message } from 'svelte-ant-design';
let stacked = $state(false);
let opened = $state(0);
// stack is a setting of message.config(): true collapses the messages into a pile after 3 of them (or { threshold }).
$effect(() => {
message.config({ stack: stacked ? { threshold: 3 } : undefined });
return () => message.config({ stack: undefined });
});
</script>
<!-- The newest message is the first row. Past the threshold the others lie behind it; the pointer or focus opens the
pile, and every timer waits while it is open. -->
<div class="stack">
<div class="row">
<Switch bind:checked={stacked} aria-label="stack" />
<span>stack {stacked ? 'on, threshold 3' : 'off'}</span>
</div>
<div class="row">
<Button onclick={() => message.info({ content: `Message ${++opened}: This is a stacked message.`, closable: true, duration: 10 })}>Open</Button>
<Button onclick={() => message.destroy()}>Destroy all</Button>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
</style>
<MessageHost top={72} closable labels={...} /> not mounted
<script lang="ts">
import { Button, MessageHost, Switch, message } from 'svelte-ant-design';
let mounted = $state(false);
</script>
<!-- <MessageHost> draws the messages where you put it. Its props are the settings and win over message.config().
Without one the library makes its own layer. Only one host is active at a time. -->
{#if mounted}
<MessageHost top={72} closable labels={{ close: 'Dismiss', success: 'Done', error: 'Failed' }} />
{/if}
<div class="stack">
<div class="row">
<Switch bind:checked={mounted} aria-label="MessageHost" />
<span><MessageHost top={72} closable labels={...} /> {mounted ? 'mounted' : 'not mounted'}</span>
</div>
<div class="row">
<Button onclick={() => message.success('Saved')}>success</Button>
<Button onclick={() => message.error('Upload')}>error</Button>
</div>
</div>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
</style>
a modal dialog
<script lang="ts">
import { tick } from 'svelte';
import { Button, message } from 'svelte-ant-design';
const KEY = 'container-dialog';
let dialog = $state<HTMLDialogElement | null>(null);
// Null before the first press; then where the layer was found: in the body or in the dialog.
let placed = $state<'body' | 'dialog' | null>(null);
// `container` is a setting of message.config(): the element that the layer is put in (the body by default). A native modal
// <dialog> is shown in the top layer of the browser, over everything that is outside of it, and nothing outside it can be reached.
// So a layer in the body is covered by the dialog, and a layer in the dialog stands above it and can be used. The setting is
// given back (and the message closed) when the dialog closes, and when the example is left, so that the page is not touched.
async function show(inDialog: boolean) {
if (!dialog) return;
message.config({ container: inDialog ? dialog : undefined });
message.info({
key: KEY,
content: inDialog ? 'In the dialog' : 'In the body',
duration: 8,
closable: true,
class: 'container-demo'
});
await tick();
placed = dialog.contains(document.querySelector('.container-demo')) ? 'dialog' : 'body';
}
function release() {
message.destroy(KEY);
message.config({ container: undefined });
placed = null;
}
$effect(() => {
return () => message.config({ container: undefined });
});
</script>
<div class="stack">
<div class="field">
<span class="caption">a modal dialog</span>
<div class="row">
<Button onclick={() => dialog?.showModal()}>Open the dialog</Button>
</div>
</div>
</div>
<dialog bind:this={dialog} aria-label="The container example" onclose={release}>
<div class="stack">
<div class="field">
<span class="caption">container: not set (the body)</span>
<Button onclick={() => show(false)}>Show a message</Button>
<span class="out" role="status">
{#if placed === 'body'}
The layer is in the body. The dialog covers it, and the message cannot be reached.
{:else}
Press to see where the layer goes.
{/if}
</span>
</div>
<div class="field">
<span class="caption">container: the dialog</span>
<Button onclick={() => show(true)}>Show a message</Button>
<span class="out" role="status">
{#if placed === 'dialog'}
The layer is in the dialog. The message stands above it and can be closed.
{:else}
Press to see where the layer goes.
{/if}
</span>
</div>
<div class="row">
<Button onclick={() => dialog?.close()}>Close the dialog</Button>
</div>
</div>
</dialog>
<style>
.stack {
display: grid;
justify-items: start;
gap: 16px;
}
.field {
display: grid;
justify-items: start;
gap: 8px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.caption {
color: var(--ads-color-text-secondary);
font-size: 12px;
}
.out {
min-height: 36px;
color: var(--ads-color-text-secondary);
font-size: 12px;
line-height: 18px;
}
dialog {
box-sizing: border-box;
width: min(420px, calc(100vw - 32px));
padding: 20px 24px;
border: 1px solid var(--ads-color-border);
border-radius: var(--ads-radius-lg);
background: var(--ads-color-bg-container);
color: var(--ads-color-text);
}
/* Dark enough to show that what stands under it is covered. */
dialog::backdrop {
background: rgb(0 0 0 / 55%);
}
</style>
API
Options of a message
| Property | Description | Type | Default |
|---|---|---|---|
| type | The kind. Only for message.open; the typed methods fix it. | 'info' | 'success' | 'error' | 'warning' | 'loading' | 'info' |
| content | The text or the content: a string, a number (0 is shown) or a snippet. | string | number | Snippet | — |
| duration | Seconds before the message goes. 0 keeps it until it is closed. A negative or not finite value falls back to the default, with a warning while developing. | number | 3 |
| icon | Replaces the icon of the type: a string (shown as text), a snippet, or false for none. | string | Snippet | false | the icon of the type |
| key | A call with the key of an open message updates that message in place (new type, content and options, the timer starts again). Without one a key is generated. | string | number | generated |
| pauseOnHover | Holds the timer while the pointer (a mouse or a pen) is over the box. Focus inside and a hidden page hold it whatever this says. | boolean | true |
| closable | Shows a close button. Ant Design has no such option. | boolean | false |
| class | Extra classes of the box. | string | — |
| style | Inline style of the box: a string, or an object of CSS properties (kebab-case or custom properties; numbers are written as they are). | string | Record<string, string | number> | — |
| classNames | Extra classes for the parts root, wrapper, icon, title and close. A value here wins over the one of the host and of message.config(). | { root?, wrapper?, icon?, title?, close? } | — |
| styles | Inline styles for the same parts, as objects. | { root?, wrapper?, icon?, title?, close? } | — |
| onclick | Called with the event when the box is clicked, not when its close button is. The box cannot be reached with the keyboard: put a button in the content for an action. | (event: MouseEvent) => void | — |
| onclose | Called once, when the message starts to close, however it was closed (the timer, the returned function, destroy, maxCount, the close button, Escape). | () => void | — |
Methods
| Property | Description | Type | Default |
|---|---|---|---|
| message.open(options) | Opens a message of the kind options.type (default info), or updates the open one with the same key. | MessageHandle | — |
| message.info | success | error | warning | loading(content, duration?, onclose?) | One method for each kind. Without a window (on a server) every call does nothing and returns an inert handle. | MessageHandle | — |
| message.info | success | error | warning | loading(options) | The same with an object of options (without type). | MessageHandle | — |
| message.destroy(key?) | Closes the message with this key, or every message. Each one runs its normal exit and its onclose. | void | — |
| message.config(options) | Sets defaults for every message from now on (the settings table below). A setting given as { top: undefined } goes back to its default. | void | — |
| handle() | What a call returns: a function that closes the message. Closing a message that is closing or closed does nothing. | () => void | — |
| handle.then(onfulfilled) | The handle is thenable: the promise resolves when the message starts to close. await handle therefore waits for the close. | PromiseLike<void> | — |
Settings: message.config() and the props of MessageHost
| Property | Description | Type | Default |
|---|---|---|---|
| top | Distance of the first message from the top of the window. A number is pixels. Without it, the token --ads-message-top (8px). | number | string | 8 |
| duration | Default duration of every message, in seconds. | number | 3 |
| maxCount | At most this many open messages: the oldest closes to make room. A value below 1 or not finite is ignored. | number | — |
| container | Where the layer is moved to: an element, or a function that returns one. Default document.body. | HTMLElement | (() => HTMLElement) | document.body |
| closable | Default of closable for every message. | boolean | false |
| labels | The word a screen reader hears before the text (info, success, error, warning, loading: "Error: Upload failed") and the name of the close button (close). Pass a translation; an empty string removes a type word. | Partial<Record<'info' | 'success' | 'error' | 'warning' | 'loading' | 'close', string>> | 'Info', 'Success', 'Error', 'Warning', 'Loading', 'Close' |
| classNames | Defaults for the parts of every message, and the two parts of the layer: list (the fixed layer) and listContent (the column of rows). | { root?, wrapper?, icon?, title?, close?, list?, listContent? } | — |
| styles | The same for inline styles, as objects. | { root?, wrapper?, icon?, title?, close?, list?, listContent? } | — |
| stack | true, or { threshold }: the newest message is the first row, and past the threshold (3) the others lie behind it as a pile that the pointer or focus opens. React 6.4.0 has it, Vue and Angular do not. | boolean | { threshold?: number } | false |
Differences from Ant Design: the layer is made by the library (the React
useMessage and contextHolder are replaced by <MessageHost>); a role per type and a hidden type word (React: role="alert" for all, Vue and Angular: none); closable is new, and the timer also waits for focus and a hidden page; duration is in seconds as in React and Vue (Angular: milliseconds); stack is in React 6.4.0 only. Not taken: the Vue warn alias, prefixCls and rtl (the direction is inherited). API inspired by Ant Design (MIT); the implementation is original for Svelte.Design tokens
| Token | Description | Default |
|---|---|---|
| --ads-message-z-index | Layer of the messages, above every popup (the tooltip is 1070). | 2010 |
| --ads-message-top | Distance of the first message from the top, when top is not set. | 8px |
| --ads-message-gap | Gap between two messages. | 16px |
| --ads-message-margin-inline | Space kept free at the left and right edge of the window. | 24px |
| --ads-message-bg | Background of the box. In the dark theme #1f1f1f. | #ffffff |
| --ads-message-color | Text color. In the dark theme 85% white. | rgba(0, 0, 0, 0.88) |
| --ads-message-padding | Padding of the box. | 9px 12px |
| --ads-message-line-height | Height of a line of text, and of the icon, so the box is 40px high with or without an icon. | 22px |
| --ads-message-radius | Corner radius of the box. | 8px |
| --ads-message-shadow | Shadow of the box. | 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05) |
| --ads-message-icon-size | Size of the icon. | 16px |
| --ads-message-icon-gap | Gap between the icon, the text and the close button. | 8px |
| --ads-message-icon-info | Color of the info and loading icons. | #1677ff |
| --ads-message-icon-success | Color of the success icon. tokens-accessible.css darkens it to #389e0d (3:1 on the white box). | #52c41a |
| --ads-message-icon-error | Color of the error icon. | #ff4d4f |
| --ads-message-icon-warning | Color of the warning icon. tokens-accessible.css darkens it to #c27c00. | #faad14 |
| --ads-message-close-size | Size of the close button: 24px, the smallest target of WCAG 2.5.8. | 24px |
| --ads-message-close-color | Color of the close button (4.5:1 on the box). | rgba(0, 0, 0, 0.65) |
| --ads-message-close-color-hover | Color of the close button on hover. | rgba(0, 0, 0, 0.88) |
| --ads-message-close-bg | Background of the close button at rest: it shows where the button is. | rgba(0, 0, 0, 0.04) |
| --ads-message-close-bg-hover | Background of the close button on hover. | rgba(0, 0, 0, 0.1) |
| --ads-message-motion-offset | How far above its place a message starts to come in and ends to leave. | 64px |
| --ads-message-stack-offset | Step between the rows of a pile. | 8px |
| --ads-message-stack-scale-step | How much smaller each row of a pile is than the one in front of it. | 0.06 |
Accessibility
errorandwarningarerole="alert"and are read out at once;info,successandloadingarerole="status"and wait for the reader to finish. Ant Design React givesrole="alert"to all five, Vue and Angular give none.- The icon is decorative. A hidden word before the text names the type ("Error: Upload failed"), so the type is not only a color and a shape. Pass translations in
labels: the library has no locale system yet and the default is English. - A message never takes focus. Without
closablenothing in it can be focused; with it, only the close button can (24px, the target size of WCAG 2.5.8).Escapecloses the message that has focus inside it. - The timer waits while the pointer is over the message, while focus is inside it and while the page is hidden. A message that must stay needs
duration: 0, andclosablelets the user dismiss it. - The layer is the last element of its container, so the keyboard reaches a close button only after the rest of the page, and there is no shortcut that moves focus to the messages. A screen reader reads a message when it opens.
- Contrast: the text is about 15:1 on the box, and the type icons are held to 3:1 (in the dark theme, and in the light theme with
tokens-accessible.css, which darkens the green and the amber). - In forced-colors modes such as Windows High Contrast the box and the close button are drawn with a border. The motion (the box comes in from above and fades) is off under
prefers-reduced-motion; the timer is the same. - Checked with a real screen reader (Orca with Firefox): it reads the role, the type word, the text, the new text after an update and the name of the close button. Not checked: whether a screen reader announces a message when it opens (the Orca setup does not speak even a plain
role="alert"), NVDA, JAWS, VoiceOver, a phone screen reader, a real touch device and a real Safari.