Reputation: 2372
I am building a component that requires to hide input by adding a css property of opacity to 0. But the look and feel of this component is a button. The reason to hide input is for selection purpose. Input element supports radio type.
Question1: What are the implications of wrapping a button around the form elements? Is there any accessibility issue?
Question2: Instead of a <button>
tag, is it better to use perhaps a <fieldset>
?
Below is the Vue template for the component?
<template>
<button :class="[$style['button-group-item'], sizeClass, classObject, variationClass]">
<label class='button-group-item__label'>
<input class="button-group-item__input" type="radio" :checked="checked" @change="$emit('change', $event.target.checked)"/>
<span>
{{ text }}
</span>
</label>
</button>
</template>
Upvotes: 1
Views: 860
Reputation: 772
Yes, there will be accessibility issues.
1) Using Button will confuse the voice over software. The focus states will also behave incorrectly (keyboard focus).
2) At the code level, you need to prevent the default behavior of Button.
3) You are Breaking the rules of the semantic tag of the HTML5
4) Do not use Button if you are not doing any action. Make the fieldset from CSS look like a button.
Upvotes: 1
Reputation: 14862
You shouldn't wrap your input+label in a button. The result is going to be weird:
For all these reasons, I heavily discourage you from using a button. Using a fieldset is much better, it's the normal way to go here. Use CSS to make your fieldset look like a button.
Upvotes: 4