Skip to content

[FEAT] : Add a Copy Button for Code Blocks #2663

Description

@KeepQuite-cyber

Please read this first:

This is the issue tracker for the website at djangoproject.com, not for Django itself.

If you are looking for help or support with using Django, please follow the links in our documentation.

If you want to submit a bug report or a feature request to Django (including documentation), you can find instructions here.

If you want to report a bug on translations in Django or djangoproject.com, please use Transifex.

Description :-

Currently, code snippets displayed in the documentation require users to manually select and copy each line of code.

Problem :-

When viewing code examples, there is no quick way to copy the entire code block. Users must manually highlight the code, which becomes inconvenient for larger examples.

Proposed Solution :-

Add a "Copy" button at the top-right corner of every code block. When clicked:

  • The entire code block should be copied to the clipboard.
  • A success message such as "Copied!" should be displayed briefly.
  • The button should work on desktop and mobile devices.

Benefits :-

  • Improves user experience.
  • Speeds up copying code examples.
  • Reduces the chance of missing lines while copying.

Mockup :

Current :

Image

Proposed :

Image

If this feature request is accepted, I'd be happy to work on an implementation and submit a pull request.

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