Skip to content

Use <label> HTML element for input labels #7281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Devessier opened this issue Sep 27, 2024 · 0 comments · Fixed by #7609
Closed

Use <label> HTML element for input labels #7281

Devessier opened this issue Sep 27, 2024 · 0 comments · Fixed by #7609
Assignees

Comments

@Devessier
Copy link
Contributor

Scope & Context

Many form components use labels. Most of the time, the labels are <div> elements. See:

const StyledLabel = styled.span`
color: ${({ theme }) => theme.font.color.light};

const StyledLabel = styled.span`
color: ${({ theme }) => theme.font.color.light};

Sometimes, the id linking a label with an input is a UUID v4. See:

Technical inputs

Labels should use the <label> HTML element for accessibility and UX concerns.

Using a UUID as a label ID is not recommended. UUIDs are cryptographically strong identifiers with low collision probability and are slow to compute. Label IDs should not be generated at each render; it's best not to change them too much to not disturb assistive technologies. We should prefer the new useId() React hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant