Skip to content

Feature: Add “Copy” button to all code blocks (pre > code) in docs (persisted UX & accessible) #3014

@shibadityadeb

Description

@shibadityadeb

Summary
Add a small “Copy” button to every code block (

) across documentation pages (including installation guides). The button copies the code to clipboard, gives immediate visual feedback (e.g. “Copied!”), is keyboard accessible, and works for dynamically rendered content (client-side navigation). Use progressive enhancement (works if JavaScript is enabled; if not, code remains readable).

Why

Improves developer DX: copying long commands / snippets is tedious without a one-click button.

Standard expectation for docs & reduces copy/paste errors.

Accessibility-friendly copy affordance helps keyboard & screen-reader users.

Proposed solution

Add a small Vue 2 client-side enhancement that:

Finds all

 blocks and inserts a copy button.

Uses the modern Clipboard API with a robust fallback.

Shows visual feedback (tooltip text changes to “Copied!” then reverts).

Supports keyboard activation and has appropriate aria-* attributes.

Handles dynamically inserted code blocks (MutationObserver).

Minimal CSS to match docs styling.

Add a single small global CSS file for the copy button.

Add tests/manual checklist.

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