balmjs / balm-ui

:diamonds: A modular and customizable UI library based on Material Design and Vue
https://material.balmjs.com
MIT License
506 stars 30 forks source link

Accessibility: Textfields are missing Labels #29

Closed schellmax closed 3 years ago

schellmax commented 3 years ago

As mentioned in the docs at https://material.balmjs.com/#/data-input/textfield Textfield labels are passed through the default slot:

<ui-textfield>Label Text</ui-textfield>

and end up in the rendered HTML wrapped in a 'span' tag:

<span class="mdc-floating-label">Label Text</span>

In the original Material Design Component at https://material-components.github.io/material-components-web-catalog/#/component/text-field the appropriate 'label' element is used instead:

<label for="text-field-hero-input" class="mdc-floating-label">Name</label>

There is also a 'label' prop mentioned in the docs, but it seems not to be used by the component.

Label elements are critical for accessibility and should therefore be used for every form input. Balm UI already uses label elements e.g. for checkbox components; usage in Textfields would be highly appreciated.

elf-mouse commented 3 years ago

Thanks @schellmax ,

When BalmUI is 6.x, I use <label> tag for floating label, then modify it to <span> tag according to the official document.

I also think it is better to use <label>, and I will improve it as soon as possible :)

elf-mouse commented 3 years ago

Hi @schellmax ,

It's improved.

Thanks again :)

schellmax commented 3 years ago

nice!