Skip to main content
🎉 A11y Issue Detection Agent is now live! Detect accessibility issues like a WCAG expert with AI. Try now!
No Result Found
Connect & Get help from 6000+ developers on our Discord community. Ask the CommunityAsk the Community

undeclared-input

Rule Severity : Serious

Description

Custom-built input elements must have an appropriate ARIA role. When you use non-semantic elements like <div> or <span> to create interactive controls, assistive technologies cannot programmatically determine their purpose.

The undeclared-input rule ensures that users of screen readers and other assistive tools understand the function of your custom components. This rule aligns with WCAG Success Criterion 4.1.2 (Name, Role, Value), which requires that the name and role of every user interface component can be programmatically determined.

Examples

In the following example, a <span> is used to create a custom toggle, but it lacks a role to identify it as a checkbox or switch.

Incorrect Sample
Copy icon Copy

In the following corrected example, role=”checkbox” is added to the element so assistive technologies can identify it correctly:

Correct Sample
Copy icon Copy

How to fix?

To fix violations of the undeclared-input rule, follow these steps:

  • Identify custom elements (like <div> or <span>) that function as interactive inputs.

  • Adding an input tag is the appropriate way of identifying an input element. Assign the appropriate ARIA role to the element, such as role="button", role="checkbox", role="radio", or role="textbox".

  • Verify that the element is also keyboard-accessible and provides necessary state information (like aria-checked).

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