Toast

Accessibility

Accessibility props

NameTypeDescription
role"status" \| "alert"The ARIA role for the toast. Use "alert" for important notifications requiring immediate attention
aria-live"polite" \| "assertive" \| "off"Controls how urgently screen readers announce the content. The difference between values is described in Best practices section.
createToast("Your message", {
ariaProps: {
role: "alert",
"aria-live": "assertive",
},
});

Automatic accessibility features

  • Focus management: Toasts do not steal focus from the user’s current task, maintaining keyboard navigation flow
  • Animation pausing: Hover over toasts pauses the dismissal countdown, giving users more time to read lengthy messages

Keyboard and screen reader experience

  • Visual notifications: Toasts appear visually and are automatically announced to screen readers
  • Keyboard focus: Toasts don’t steal keyboard focus, allowing users to continue their current task
  • Mouse hover: Pauses the toast dismissal timer
  • Mouse leave: Resumes the toast dismissal timer

Best practices

  • Keep messages concise: Use clear, brief messages that can be quickly read and understood
  • Use appropriate roles:
    • Use role="status" for non-critical information (default)
    • Use role="alert" only for important messages requiring immediate attention
  • Set appropriate aria-live values:
    • Use aria-live="assertive" only for critical messages, interrupts the current task to announce the message
    • Use aria-live="polite" for most messages (default), waits for finish of prioritized announcements
    • Use aria-live="off" for toasts that are not so urgent, announces the message once current task is finished and trigger element still has focus (if exists)
  • Avoid too many toasts: Limit the number of simultaneous toast notifications to prevent overwhelming users
  • Consider message duration: Set an appropriate dismissTimeout based on message length and importance
  • Provide context: Ensure messages make sense when announced out of context by screen readers
  • Translation: Ensure all toast content is properly localized for international users

Examples

Basic informational toast

import { createToast } from "@kiwicom/orbit-components/lib/Toast";
createToast("Your changes have been saved");

Critical error toast

import { createToast } from "@kiwicom/orbit-components/lib/Toast";
import AlertCircle from "@kiwicom/orbit-components/lib/icons/AlertCircle";
createToast("Payment unsuccessful. Please try again.", {
icon: <AlertCircle />,
ariaProps: {
role: "alert",
"aria-live": "assertive",
},
});

Promise-based toast

import { createToastPromise } from "@kiwicom/orbit-components/lib/Toast";
createToastPromise(
saveDataPromise,
{
loading: "Saving your changes...",
success: "Changes saved successfully",
error: "Failed to save changes",
},
{
// Global aria props for all states
ariaProps: {
role: "status",
"aria-live": "polite",
},
// Override aria props for error state
error: {
ariaProps: {
role: "alert",
"aria-live": "assertive",
},
},
},
);