Repository navigation
Replies: 4 comments 5 replies
|
IMHO: create an
|
0 replies
|
My 2 cents:
|
2 replies
|
About
|
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
This RFC proposes a new approach to handling icon accessibility across the codebase. The core change is to make all icons
aria-hiddenby default and introduce aVisuallyHiddencomponent or use a Tooltip to set an accessible name for cases where icons carry semantic meaning in interactive elements.Motivation
Currently, icons throughout our interfaces are exposed to assistive technologies even when they are decorative. This pollutes the accessibility tree and creates a noisy experience for screen reader users.
When icons are informative (e.g., inside buttons), the current approach of deriving labels from icon names is problematic:
ArrowRight→ "Next")aria-labelare not ideal because they often gets overlooked in automatic browser translation and screen reader support is not as good as visually hidden content.Proposal
1. All Icons Are
aria-hiddenIcons should be decorative by default and always include
aria-hidden="true".2. Introduce
VisuallyHiddenComponentCreate a reusable
<VisuallyHidden>component for semantically meaningful content that should remain invisible to sighted users but available to assistive technologies.3. Label Handling
How to set an accessible name when icons carry meaning.
3.1 Accessible label in a tooltip
A tooltip can carry the label of an icon button using an
aria-labelledbyattribute on the button that targets the tooltip containing the label.3.2 Visually hidden label without tooltip
If we want to set an accessible label without having a tooltip, we can use the
VisuallyHiddencomponent to carry the label. This should be relatively rare (prefer a tooltip in most case to clarify the label for sighted users).3.3 Description in a tooltip
The tooltip can display an auxiliary description which brings additional details to the label: e.g. a button with label "Notifications" and description "View and manage notifications settings".
In that case the button still needs an accessible label. This label can either be a visible content, or hidden using
VisuallyHiddenin an icon button for instance. The tooltip is linked to the button with anaria-describedbyattribute.Open Questions
Q1: How to create the tooltip(s) for accessible name and description
When an icon is used without visible text (e.g., icon-only button), how do we set the tooltip with the label ?
Proposed approaches:
1. Using the tooltip component
Use the existing Tooltip component with the icon button
aria-labelin existing codebasesVisuallyHidden, like theTextInput. In that case a property might be needed anyway, which is the other option below.The same approach could be used to set a description in the Tooltip: add a visible content in the Button as the label, and use a Tooltip component with
aria-describedbyfor the description.2. Using a dedicated property
accessibleNameAdd a property in the Button that renders the label in a Tooltip
aria-labelaccessibleName(only text) or render it next to the children (icon + text)TextInputto have a hidden label (which doesn't have to be in a Tooltip, could beVisuallyHidden)accessibleNamewill render a tooltip (but maybe it's not a bad thing)The same approach could be used to set a description using an
accessibleDescriptionproperty, which will render the description in a Tooltip witharia-describedby. If anaccessibleNameANDaccessibleDescriptionare provided, the label can be rendered inVisuallyHiddenand the description in tooltip.Important note: the Button component already has a
tooltipproperty but we can't choose if it's a label or a description. We could deprecate it in favor ofaccessibleName/accessibleDescription.Q2: Can we generalize a pattern in other components ?
In order to be consistent, we should also migrate other components currently using
aria-label. The previous question still applies: how do we set the label(s) ?1. Keep existing
labelprops and hide themAdd a property to visually hide
<label>elements instead of usingaria-label2. Reuse the same
accessibleNameproperty as proposed beforeEach component can decide if the
accessibleNameis rendered in a tooltip (like the Button) or in theVisuallyHiddencomponent (like the TextInput)Implementation Considerations
aria-labelprops. If we choose to use theaccessibleNameproperty, we could use thearia-labelif it's present, and thetooltipprop of the Button, which would provide an automatic migration for existing codebases.Decision
After discussions and vote, here are the final decisions:
tooltipLabelandtooltipDescriptionon theButtoncomponent and all other components that can have a tooltip label or description.accessibleLabelon components that can have a hidden label without a tooltip, likeSearchInputsr-onlyCSS class that can be added to hide a content while keeping it accessible to assistive technologiesVisuallyHiddencomponent which renders a content with thesr-onlyclass. Use anasprop to personalize the tag and forward all propertiesNext Steps
VisuallyHiddencomponentChangelog
Comments and feedback welcome. Please respond in the associated discussion thread.
All reactions