Skip to content

Commit fef8a69

Browse files
committed
fix(a11y): add aria-label to icon-only links in Sandpack toolbar
The OpenInTypeScriptPlayground and OpenInCodeSandbox buttons hide their text labels on mobile (hidden md:block), leaving only an icon visible. Screen readers could not determine the link purpose since title alone is insufficient per WCAG 2.4.4 (Link Purpose). Add aria-label to both components so screen readers always announce the link purpose regardless of viewport size. Fixes #8366
1 parent 1207ee3 commit fef8a69

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/components/MDX/Sandpack/OpenInCodeSandboxButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export const OpenInCodeSandboxButton = () => {
1616
return (
1717
<UnstyledOpenInCodeSandboxButton
1818
className="text-sm text-primary dark:text-primary-dark inline-flex items-center hover:text-link duration-100 ease-in transition mx-1 ms-2 md:ms-1"
19-
title="Open in CodeSandbox">
19+
title="Open in CodeSandbox"
20+
aria-label="Open in CodeSandbox">
2021
<IconNewPage
2122
className="inline mx-1 relative top-[1px]"
2223
width="1em"

src/components/MDX/Sandpack/OpenInTypeScriptPlayground.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const OpenInTypeScriptPlaygroundButton = (props: {content: string}) => {
2020
contentWithReactImport
2121
)}`}
2222
title="Open in TypeScript Playground"
23+
aria-label="Open in TypeScript Playground"
2324
target="_blank"
2425
rel="noreferrer">
2526
<IconNewPage

0 commit comments

Comments
 (0)