Skip to content

Getting Started

The Color Chips plugin extends Expressive Code to display a preview “chip” for colors in CSS code blocks. This guide will show you how to add it to your website.

Set-up

  1. Install the expressive-code-color-chips dependency using your preferred package manager:

    Terminal window
    npm i expressive-code-color-chips
  2. Add the plugin to your site’s Expressive Code configuration:

    astro.config.mjs
    import { defineConfig } from 'astro/config';
    import astroExpressiveCode from 'astro-expressive-code';
    import { pluginColorChips } from 'expressive-code-color-chips';
    export default defineConfig({
    integrations: [
    astroExpressiveCode({
    plugins: [pluginColorChips()],
    }),
    ],
    });
  3. That’s it! Colors in CSS code blocks will now be annotated with a small preview.

Usage

There is no specific syntax for this plugin. It detects CSS color syntax in code blocks tagged with css and annotates all valid colors it finds.

For example the following Markdown code:

```css
.example {
color: goldenrod;
}
```

Renders a code block with a chip next to the color goldenrod:

.example {
color: goldenrod;
}

In addition to css, this plugin also runs for scss, sass, less, and stylus code blocks. For example:

```scss
$primary: fuchsia;
```

Which renders as:

$primary: fuchsia;

Support

This is open-source software. If you run into any bugs, please report issues on GitHub.