Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/common-streets-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"streamdown": minor
---

Added accessibility improvements for code block controls by adding aria labels to copy/download buttons and announcing copy success state for screen readers.
34 changes: 21 additions & 13 deletions packages/streamdown/lib/code-block/copy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,27 @@ export const CodeBlockCopyButton = ({
const Icon = isCopied ? icons.CheckIcon : icons.CopyIcon;

return (
<button
className={cn(
"cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",
className
<>
<button
aria-label={t.copyCode}
className={cn(
"cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",
className
)}
data-streamdown="code-block-copy-button"
disabled={isAnimating}
onClick={copyToClipboard}
title={t.copyCode}
type="button"
{...props}
>
{children ?? <Icon size={14} />}
</button>
{isCopied && (
<output aria-live="polite" className="sr-only">
{t.copied}
</output>
)}
data-streamdown="code-block-copy-button"
disabled={isAnimating}
onClick={copyToClipboard}
title={t.copyCode}
type="button"
{...props}
>
{children ?? <Icon size={14} />}
</button>
</>
);
};
1 change: 1 addition & 0 deletions packages/streamdown/lib/code-block/download-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ export const CodeBlockDownloadButton = ({

return (
<button
aria-label={t.downloadFile}
className={cn(
"cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",
className
Expand Down
Loading