Skip to content

Conversation

metonym
Copy link
Owner

@metonym metonym commented Sep 1, 2025

Closes #343, closes #351

For highlighted code snippets, a copy button is basic affordance.

From a design standpoint, this library is modularized. For example, line numbers are not included by default to minimize the amount of code shipped to the end user. Similarly, even though a copy button is common, it should be opt-in.

This PR is an initial pass when adding a copy button.

Requirements

  • Must be opt-in
  • Must work and be composable with all scenarios: Highlight, HighlightSvelte, LineNumbers, with language tag etc..
  • Must have reasonable defaults (e.g., a 2 second auto-timeout) but be easy to customize
  • Must be accessible/semantic

Implementation Notes

  • The difficulty is composition. Because of the modular design of this library, we must avoid using context to auto-detect features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Copy Button
1 participant