ARIA roles without their required attributes leave screen reader users guessing about element state.
When you assign an ARIA role to an element, certain attributes become mandatory. These required attributes tell assistive technologies the current state of the element. Without them, a screen reader might announce "checkbox" but have no way to convey whether it's checked or unchecked.
role attribute is presentCommon roles and their required attributes:
role="checkbox" requires aria-checkedrole="combobox" requires aria-expanded and aria-controlsrole="slider" requires aria-valuenow, aria-valuemin, aria-valuemaxrole="scrollbar" requires aria-controls, aria-valuenow, aria-valuemin, aria-valuemaxrole="heading" requires aria-levelFor a custom checkbox missing aria-checked:
<!-- Before: Missing required attribute -->
<div role="checkbox" tabindex="0">
Accept terms
</div>
<!-- After: Complete with required attribute -->
<div role="checkbox" aria-checked="false" tabindex="0">
Accept terms
</div>
Update the attribute dynamically when state changes:
checkbox.addEventListener('click', () => {
const isChecked = checkbox.getAttribute('aria-checked') === 'true'
checkbox.setAttribute('aria-checked', !isChecked)
})
Native elements handle required states automatically:
<!-- Native checkbox - no ARIA needed -->
<label>
<input type="checkbox" name="terms">
Accept terms
</label>
<!-- Native slider - no ARIA needed -->
<input type="range" min="0" max="100" value="50">
Custom sliders need multiple attributes:
<!-- Complete slider implementation -->
<div
role="slider"
aria-valuenow="50"
aria-valuemin="0"
aria-valuemax="100"
aria-label="Volume"
tabindex="0"
>
<div class="slider-thumb"></div>
</div>
<script setup>
const props = defineProps(['label'])
const isChecked = ref(false)
</script>
<template>
<div
role="checkbox"
:aria-checked="isChecked"
tabindex="0"
@click="isChecked = !isChecked"
@keydown.space.prevent="isChecked = !isChecked"
>
{{ label }}
</div>
</template>
aria-checked="" is invalid. Use "true" or "false".<input type="checkbox"> handles all states automatically.Required attribute issues often appear alongside:
Missing required ARIA attributes often appear in reusable components across your site. Unlighthouse scans every page automatically, finding all instances where roles lack their required attributes, so you can fix components once and improve accessibility everywhere.