Skip to content

a11y: code-block control buttons are title-only — no aria-label, no copy-success live region #556

Description

@hrminator

Summary

In streamdown 2.5.0 the built-in code-block controls (CodeBlockCopyButton, CodeBlockDownloadButton) expose their purpose only via the title attribute, and the copy-success feedback is purely visual (CopyIcon → CheckIcon swap for 2s).

Two gaps for assistive tech:

  1. No aria-label on the buttons. title does work as an accessible-name fallback, but it's the weakest source (inconsistent SR support, no touch exposure) — an explicit aria-label mirroring the existing translations keys (copyCode, downloadFile) would be strictly better and is already localizable through the same prop.
  2. No live region for copy success. WCAG 2.1 SC 4.1.3 (Status Messages) wants the "Copied" state exposed without focus movement — e.g. a visually-hidden sibling <span role="status"> whose text flips to translations.copied during the 2s success window. Today a screen-reader user gets no confirmation the copy happened.

Searched the dist: no aria-live/role="status" anywhere in the package.

Suggested fix

  • aria-label={translations.copyCode} (and per-button equivalents) on all control buttons.
  • A sr-only role="status" span in the actions wrapper announcing translations.copied while the success state is active.

Happy to PR either if there's interest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions