Skip to content

Getting Started

The Collapsible plugin enhances Expressive Code blocks on your website by automatically collapsing long code blocks with expand/collapse controls, keeping your documentation clean and readable.

This guide will show you how to add it to your website.

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

    Terminal window
    npm i expressive-code-collapsible
  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 { pluginCollapsible } from 'expressive-code-collapsible';
    export default defineConfig({
    integrations: [
    astroExpressiveCode({
    plugins: [pluginCollapsible()],
    }),
    ],
    });
  3. That’s it! The Collapsible plugin works out of the box with sensible defaults.

For more information on how to configure the plugin, see the Configuration page.

This plugin is open-source software licensed under the MIT license. If you run into any bugs, please report issues on GitHub.