DEV Community

Luiz Américo
Luiz Américo

Posted on • Originally published at blikblum.dev on

Adding copy code feature to code blocks in Astro

I was looking for a way to add a copy code feature to code blocks in my blog, built with Astro. A google search led me to a few articles. The first four suggested home made solutions. The fifth was not exactly an article on how to add the feature but a Astro development discussion that quoted, in passing, the package used by Starlight.

That's it, to add a copy code feature to your code blocks in Astro, just install astro-expressive-code:

yarn astro add astro-expressive-code

# or

npx astro add astro-expressive-code

Enter fullscreen mode Exit fullscreen mode

Besides code copying, the package also provides other features.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)