diff --git a/change/@fluentui-react-badge-a8f819d6-e17b-4f87-9dd2-68eb2f87f168.json b/change/@fluentui-react-badge-a8f819d6-e17b-4f87-9dd2-68eb2f87f168.json new file mode 100644 index 0000000000000..5e9812133c7e1 --- /dev/null +++ b/change/@fluentui-react-badge-a8f819d6-e17b-4f87-9dd2-68eb2f87f168.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "remove aria-hidden from badge", + "packageName": "@fluentui/react-badge", + "email": "mgodbolt@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-components/react-badge/src/BadgeBestPractices.md b/packages/react-components/react-badge/src/BadgeBestPractices.md index a4a88bd965738..c98676303da55 100644 --- a/packages/react-components/react-badge/src/BadgeBestPractices.md +++ b/packages/react-components/react-badge/src/BadgeBestPractices.md @@ -10,12 +10,37 @@ ### Screen Readers -- Badges should be given a meaningful description. This description will be applied, via “aria-describedby” to the element decorated by the Badge. For example, "Chat, 6 unread" or similar. - General guidance is that the badge icon is marked as “aria-hidden” by default. +Badge content is exposed as text, and is treated by screen readers as if it were inline content of the control it is associated with. This should provide a reasonable default for most badges that contain plain text, such as the `CounterBadge`. + +There are two actions authors should consider taking when using Badge to improve this experience: + +1. If the badge contains a custom icon, that icon must be given alternative text with `aria-label`, unless it is purely presentational: + +```jsx +} /> +``` + +2. If the text of the badge itself is not sufficient to convey its meaning, it can either be given additional hidden text, or the parent element given an explicit label: + +```jsx + + + +``` ### Badge shouldn't rely only on color information -- Include meaningful descriptions when using color to represent meaning in a badge. If relying on color only [unread dot] ensure that non-visual information is included using aria-describedby +- Include meaningful descriptions when using color to represent meaning in a badge. If relying on color only [unread dot] ensure that non-visual information is included in the parent's label or description. Alternatively, mark up the Badge as an image with a label: + +```jsx +} /> +``` ### Text on Badge diff --git a/packages/react-components/react-badge/src/components/Badge/__snapshots__/Badge.test.tsx.snap b/packages/react-components/react-badge/src/components/Badge/__snapshots__/Badge.test.tsx.snap index 91f1d3f77d297..c770879196ec9 100644 --- a/packages/react-components/react-badge/src/components/Badge/__snapshots__/Badge.test.tsx.snap +++ b/packages/react-components/react-badge/src/components/Badge/__snapshots__/Badge.test.tsx.snap @@ -2,7 +2,6 @@ exports[`Badge renders a default state 1`] = `
Default Badge diff --git a/packages/react-components/react-badge/src/components/Badge/useBadge.ts b/packages/react-components/react-badge/src/components/Badge/useBadge.ts index 815e40020ee87..9a8db809a2cc8 100644 --- a/packages/react-components/react-badge/src/components/Badge/useBadge.ts +++ b/packages/react-components/react-badge/src/components/Badge/useBadge.ts @@ -26,7 +26,6 @@ export const useBadge_unstable = (props: BadgeProps, ref: React.Ref }, root: getNativeElementProps('div', { ref, - 'aria-hidden': true, ...props, }), icon: resolveShorthand(props.icon), diff --git a/packages/react-components/react-badge/src/components/CounterBadge/__snapshots__/CounterBadge.test.tsx.snap b/packages/react-components/react-badge/src/components/CounterBadge/__snapshots__/CounterBadge.test.tsx.snap index c8b470f5dab50..d7ee96c8633db 100644 --- a/packages/react-components/react-badge/src/components/CounterBadge/__snapshots__/CounterBadge.test.tsx.snap +++ b/packages/react-components/react-badge/src/components/CounterBadge/__snapshots__/CounterBadge.test.tsx.snap @@ -2,7 +2,6 @@ exports[`CounterBadge renders a default state 1`] = `
0 diff --git a/packages/react-components/react-badge/src/components/PresenceBadge/__snapshots__/PresenceBadge.test.tsx.snap b/packages/react-components/react-badge/src/components/PresenceBadge/__snapshots__/PresenceBadge.test.tsx.snap index 259f4e749489a..125e76b0ddaec 100644 --- a/packages/react-components/react-badge/src/components/PresenceBadge/__snapshots__/PresenceBadge.test.tsx.snap +++ b/packages/react-components/react-badge/src/components/PresenceBadge/__snapshots__/PresenceBadge.test.tsx.snap @@ -2,7 +2,6 @@ exports[`PresenceBadge renders a default state 1`] = `