Course contentsShow
← Web Development
Lesson 1016 of 2,98218. Accessibility FundamentalsFree lesson

Widget Roles: Interactive Components

Implementing button, tab, slider, and other widget roles for custom controls.

Widget Roles: Interactive Components

You'll learn how to use ARIA widget roles to make custom interactive controls accessible to assistive technologies.

When you build custom interactive components (like dropdowns, tabs, or sliders) without using native HTML elements, screen readers don't automatically understand what these components are or how they behave. Widget roles solve this problem by explicitly telling assistive technologies: "This <div> isn't just a container—it's actually a button."

Why Widget Roles Matter

Native HTML elements like <button> come with built-in accessibility. But when you create custom controls with <div> or <span> (for design flexibility), you lose that automatic support. Widget roles restore it.

Common Widget Roles

role="button" – Identifies a clickable element that triggers an action:

<div role="button" tabindex="0">Custom Button</div>

role="tab" – Marks a tab in a tab list interface:

<div role="tab" aria-selected="true">Profile</div>

role="slider" – Indicates a range input control:

<div role="slider" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>

Other widget roles include checkbox, radio, switch, combobox, menu, menuitem, dialog, and more.

The Complete Picture

Widget roles rarely work alone. You typically combine them with ARIA states (like aria-pressed, aria-expanded) and properties (like aria-valuetext, aria-controls) to fully communicate the component's status and relationships.

Think of widget roles as job titles for HTML elements—they tell assistive technologies what function each element performs in your interface.

Key Takeaway: Widget roles transform generic HTML elements into interactive controls that assistive technologies recognize, ensuring custom components work for all users.