Skip to content

Replace Toast notifications with inline feedback for "Code Copied" action #8357

Closed

Description

@ShubhamOulkar

Description

Problem
Currently, when a user clicks the "Copy" button on a code block, the website triggers a global toast notification at the bottom of the screen to indicate success.

While visually common, this pattern introduces significant accessibility and usability issues. Recent discussions (referenced below) highlight that toast notifications are often problematic because:

  1. Timing: They often disappear too quickly for some users to read.
  2. Focus/Screen Readers: Assistive technology often misses them if focus isn't managed perfectly, leaving the user unsure if the action succeeded.
  3. Cognitive Load: They appear far away from the user's current locus of attention (the code block), making them easy to overlook.

Reference: Primer Design System: Toast Accessibility

Proposed Solution

We should remove the Toast dependency for the "Copy" action and instead implement inline feedback.

When the user clicks the copy button:

  • The feedback should appear inside the code block header, directly adjacent to or replacing the button itself.
  • Example: The copy icon could briefly change to a "Checkmark" icon, or the text "Copy" could change to "Copied!".
  • Benefit: This keeps the feedback within the user's current field of vision and is more logically associated with the trigger action.

Ref Slack message

Activity

  1. avivkeller commented on Nov 21, 2025

    @avivkeller
    Member

    Example: The copy icon could briefly change to a "Checkmark" icon, or the text "Copy" could change to "Copied!".

    To be honest, this would make the bundle a bit smaller, I imagine, since we no longer need to pass a Toast provider.

  2. ShubhamOulkar commented on Nov 21, 2025

    @ShubhamOulkar
    ContributorAuthor

    We need one state, activity component and useEffectEvent timer to toggle states. 🤔 WDYT?

  3. bmuenzenmeyer commented on Nov 21, 2025

    @bmuenzenmeyer
    Contributor

    Example: The copy icon could briefly change to a "Checkmark" icon, or the text "Copy" could change to "Copied!".

    i could have this wrong but i thought changing the text like this was less accessible. The radix toast uses aria-live features

  4. ovflowd commented on Dec 25, 2025

    @ovflowd
    Member

    Has there been any progress here?

  5. added theissue type on Dec 25, 2025
  6. ovflowd commented on Dec 25, 2025

    @ovflowd
    Member

    I feel that for the code boxes we can simply replace the text of "Copy to clipboard" to "Copied to clipboard!" and then change it back after a timeout.

  7. cnaples79 commented on Dec 25, 2025

    @cnaples79

    I'm working on this!

  8. moved this from 📋 Backlog to ✅ Done in Node.js Websiteon Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions