Skip to content

🐛 Bug Report / 💡 Feature Request #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shrilakshmishastry opened this issue May 25, 2025 · 0 comments
Open

🐛 Bug Report / 💡 Feature Request #1243

shrilakshmishastry opened this issue May 25, 2025 · 0 comments

Comments

@shrilakshmishastry
Copy link

Title: Restrict role prop to valid ARIA roles for toasts: "alert", "status", or "log"


Current behavior

The role prop on the <Toast> component (as defined here in types.ts) accepts string, meaning it can accept any value, including invalid or unintended roles.

role?: string;

Expected behavior

To improve accessibility and developer experience, the role prop should be restricted to valid ARIA roles applicable for toasts:

  • "alert" (for urgent messages)
  • "status" (for non-urgent status updates)
  • "log" (for streaming messages/logs)

Suggested type definition:

role?: 'alert' | 'status' | 'log';

This change:

  • Prevents accidental use of inappropriate roles (like "tooltip" or "dialog").
  • Aligns with WAI-ARIA spec and screen reader behavior.
  • Helps enforce accessible patterns by default.

Why this matters

Toasts are accessibility-critical components that announce messages to screen readers. Restricting the role ensures proper usage and improves reliability for assistive technology users.


Suggested fix

Update the ToastPosition type in [types.ts](https://github.com/fkhadra/react-toastify/blob/e1fa4760cea8adf28d5cf93cd14067a852b1f5c8/src/types.ts#L124) to:

role?: 'alert' | 'status' | 'log';

Additional context

More about ARIA live regions:

Happy to contribute a PR if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant