From 3251f7a207d323b56c677f643d9b28e3cf1e5c24 Mon Sep 17 00:00:00 2001
From: GCHQ-Developer-299
<111292477+GCHQ-Developer-299@users.noreply.github.com>
Date: Wed, 28 Feb 2024 09:21:16 +0000
Subject: [PATCH] docs(root): add accessible labels to chip icons
add aria-labels to the examples in IcChip's guidance pages
ref #1560
---
.../components/chips/accessibility.mdx | 4 +-
.../structured/components/chips/code.mdx | 216 ++++++++++--------
.../structured/components/chips/guidance.mdx | 4 +-
3 files changed, 122 insertions(+), 102 deletions(-)
diff --git a/src/content/structured/components/chips/accessibility.mdx b/src/content/structured/components/chips/accessibility.mdx
index beda5b4ff..2cd456ffc 100644
--- a/src/content/structured/components/chips/accessibility.mdx
+++ b/src/content/structured/components/chips/accessibility.mdx
@@ -1,7 +1,7 @@
---
path: "/components/chip/accessibility"
-date: "2023-02-03"
+date: "2024-02-28"
title: "Chip"
@@ -27,6 +27,8 @@ When an interactive chip is disabled, the `aria-disabled` tag is set to `true`.
Make sure that focus is moved to an intuitive element of the page after a chip is dismissed.
+When an icon is slotted into a chip, ensure it either has an accessible label provided through alt text on an ``, a title element within an `
@@ -97,6 +102,7 @@ export const snippetsDefault = [
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
+ aria-label="coffee"
>
@@ -115,28 +121,30 @@ export const snippetsOutline = [
{
language: "Web component",
snippet: `
-
-
-
- `,
+
+
+
+`,
},
{
language: "React",
snippet: `
-
-
-
- `,
+
+
+
+`,
},
];
@@ -155,6 +163,7 @@ export const snippetsOutline = [
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
+ aria-label="coffee"
>
@@ -167,32 +176,34 @@ export const snippetsDismissible = [
{
language: "Web component",
snippet: `
-
-
-
-
- `,
+
+
+
+
+`,
},
{
language: "React",
snippet: ` console.log(ev)}>
-
-
-
- `,
+
+
+
+`,
},
];
@@ -211,6 +222,7 @@ export const snippetsDismissible = [
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
+ aria-label="coffee"
>
@@ -228,6 +240,7 @@ export const snippetsDisabled = [
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
+ aria-label="coffee"
>
@@ -238,33 +251,36 @@ export const snippetsDisabled = [
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
+ aria-label="coffee"
>
-
+
`,
},
{
language: "React",
snippet: `
-
-
-
-
-
-
-
-
- `,
+
+
+
+
+
+
+
+
+`,
},
];
@@ -283,6 +299,7 @@ export const snippetsDisabled = [
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
+ aria-label="coffee"
>
@@ -293,6 +310,7 @@ export const snippetsDisabled = [
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
+ aria-label="coffee"
>
diff --git a/src/content/structured/components/chips/guidance.mdx b/src/content/structured/components/chips/guidance.mdx
index e7b996b9c..e13fc3546 100644
--- a/src/content/structured/components/chips/guidance.mdx
+++ b/src/content/structured/components/chips/guidance.mdx
@@ -3,7 +3,7 @@ path: "/components/chip"
navPriority: 9
-date: "2023-04-17"
+date: "2024-02-28"
title: "Chip"
@@ -188,7 +188,7 @@ Use an icon on the left of a dismissible or static chip to provide additional me
When including an icon in a chip make sure that the icon is understandable and relevant to the information presented.
-Always provide alternative descriptions for icons. Don't use icons if they aren't necessary.
+Always provide alternative descriptions for icons, or mark them as decorative. Don't use icons if they aren't necessary.
## Related components