Skip to main content
No Result Found

modal-role

Severity: Critical

Description

All modals in a webpage should have their role defined as dialog.

Assistive technologies like screen readers can easily identify a modal if defined with role="dialog". This enables a smooth experience for users of such technologies.

If the role is not defined or incorrectly defined, assistive technologies might behave unexpectedly and hamper the user experience.

Example

Consider the following example in which a modal is defined without a role.

Incorrect code sample
Copy icon Copy

Without a defined role, assistive technologies like screen readers might not identify this as a modal. This can create confusion in the user experience.

In contrast, the following example defines role="dialog" in the HTML code.

Corrected code sample
Copy icon Copy

With the role correctly defined as dialog, assistive technologies like screen readers can quickly identify the modal. This improves the user experience and the accessibility of the modal.

How to fix?

Follow these steps to fix the modal-role rule if it gets flagged:

  • Identify any modals used on your webpage.
  • Check if it defines role="dialog".
  • If the role is defined incorrectly or not defined, modify it to role="dialog".

Reference

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle