I have a unique component that generates a pill check group. The checkboxes are hidden, while the labels are displayed as nicely formatted boxes in checked and unchecked states.
Check out the InputCheckGroupPill.vue
component below:
<div class="grid grid-cols-3 sm:grid-cols-4">
<div v-for="(option, index) in options" :key="option[valueAttribute]">
<div class="text-sm ">
<input :id="'check-option-' + option[valueAttribute] + index"
:aria-describedby="'check-label-' + option[valueAttribute] + index"
:aria-activedescendant="'check-label-' + option[valueAttribute] + index"
:aria-labelledby="'check-label-' + option[valueAttribute] + index"
:value="option[valueAttribute]"
v-model="selectedOptions"
class="hidden"
type="checkbox"/>
<label :id="'check-label-' + option[valueAttribute] + index"
:for="'check-option-' + option[valueAttribute] + index"
:class="[ selectedOptions.includes(option[valueAttribute]) ? 'bg-primary-600 text-white hover:bg-primary-500 border border-r-1 border-gray-100' : 'ring-1 ring-inset ring-gray-300 bg-white text-gray-900 hover:bg-gray-50', index === 0 ? 'rounded-l-md': '', index === options.length-1 ? 'rounded-r-md': '', 'flex items-center justify-center py-3 px-3 text-sm font-semibold uppercase sm:flex-1 focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 cursor-pointer']">
{{option[labelAttribute]}}
</label>
</div>
</div>
</div>
Below is a visual representation of the component:
https://i.sstatic.net/cE9yE.png
However, I am facing an issue where the checkboxes are being skipped when navigating using the tab key.
I have tried various ARIA descriptors from MDN without success. Can you offer any assistance?
Please note that the component functions correctly with mouse interaction, but I need it to be keyboard-friendly too.
The technologies used are VueJs for functionality and Tailwind CSS for styling.