Skip to content

Commit bf440c8

Browse files
Improve accessibility and UX for copy button with screen reader support
Co-authored-by: rahul.chhabria <[email protected]>
1 parent d711096 commit bf440c8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/copyForLLMButton.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ export default function CopyForLLMButton() {
5858
) : (
5959
<ClipboardCopyIcon width="24" height="24" />
6060
)}
61-
<span className="text-sm leading-none">{copied ? 'Copied' : 'Copy for LLM'}</span>
61+
{/* Visually hidden text for screen readers */}
62+
<span className="sr-only">{copied ? 'Copied' : 'Copy for LLM'}</span>
6263
</button>
6364

6465
{showToast &&
6566
typeof document !== 'undefined' &&
6667
createPortal(
67-
<div className="fixed bottom-4 left-1/2 -translate-x-1/2 bg-[var(--gray-2)] text-[var(--gray-12)] border border-[var(--gray-a4)] px-4 py-2 rounded shadow-lg z-50">
68+
<div
69+
role="status"
70+
aria-live="polite"
71+
className="fixed bottom-4 left-1/2 -translate-x-1/2 bg-[var(--gray-2)] text-[var(--gray-12)] border border-[var(--gray-a4)] px-4 py-2 rounded shadow-lg z-50 transition-opacity duration-300"
72+
>
6873
Copied to clipboard
6974
</div>,
7075
document.body

src/components/docPage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function DocPage({
8686
</div>
8787
<div className="overflow-hidden">
8888
{leafNode && <Breadcrumbs leafNode={leafNode} />}{' '}
89-
<div className="flex items-center justify-end space-x-[5px]">
89+
<div className="ml-auto flex items-center gap-[5px]">
9090
<CopyForLLMButton />
9191
<Link
9292
rel="nofollow"

0 commit comments

Comments
 (0)