Skip to content

The Open Standard for Generative UI

fix(a11y): add dynamic aria-label to CodeBlock copy button (#478)

Olabode Felix Akinyemie8813eb956f7
diff --git a/packages/react-ui/src/components/CodeBlock/CodeBlock.tsx b/packages/react-ui/src/components/CodeBlock/CodeBlock.tsx
index c5a9cf6a2..42d217e35 100644
--- a/packages/react-ui/src/components/CodeBlock/CodeBlock.tsx
+++ b/packages/react-ui/src/components/CodeBlock/CodeBlock.tsx
@@ -32,6 +32,7 @@ export const CodeBlock = ({ language, codeString, theme }: CodeBlockProps) => {
"openui-code-block-copy-button-copied": copied,
})}
icon={copied ? <CheckCheck /> : <Copy />}
+ aria-label={copied ? "Copied to clipboard" : "Copy code"}
/>
<SyntaxHighlighter
style={theme ?? vscDarkPlus}