Skip to content

Conversation

0scarB
Copy link

@0scarB 0scarB commented Jul 5, 2025

The PR adds a "Copy CSS to clipboard" icon button to the bottom-right of each font card.

image

Regarding the implementation: It tries to use the Clipboard API first, to copy the CSS -- window.navigator.clipboard.writeText(...). Otherwise, as a fallback, the text containing the CSS is selected using the Selection API -- Selection.addRange(range) -- and document.execCommand("copy") is called to copy the CSS. If this also fails, the copy buttons are disabled by adding the "disabled" attribute. If one of the two methods for copying the CSS succeeds, the button is turned green for half a second and the icon is replaced with a checkmark for the half-second duration.

image

Open to styling changes.

If the PR is too large, feel free to close.

The execCommand fallback can be removed if it adds too much bloat and old-browser support isn't a primary concern.


Thanks for creating this very useful project. I use it all the time

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.

1 participant