You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 intypes.ts
) acceptsstring
, meaning it can accept any value, including invalid or unintended roles.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:
This change:
"tooltip"
or"dialog"
).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:Additional context
More about ARIA live regions:
alert
status
log
Happy to contribute a PR if needed!
The text was updated successfully, but these errors were encountered: