An Expressive Code plugin to expand or collapse code blocks.
npm install expressive-code-collapsibleA plugin for Expressive Code that adds collapsible functionality to code blocks, automatically collapsing long code with expand/collapse controls.


- Long code blocks automatically collapse based on a configurable line threshold
- Force collapse or expand on any block using collapse or nocollapse meta strings
- Toggle buttons appear both as an overlay and in the header (when a title is present)
- Animated transitions that respect prefers-reduced-motion
- Accessible with ARIA attributes and customizable screen reader announcements
- Works with Starlight, Astro, Next.js, and standalone Expressive Code setups
Install the plugin using your preferred package manager:
``bash`
npm install expressive-code-collapsible
`js
import { pluginCollapsible } from 'expressive-code-collapsible';
// Add to your Expressive Code configuration
plugins: [pluginCollapsible()]
``
For comprehensive documentation, installation guides, configuration options, and examples, visit the plugin documentation.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Licensed under the MIT License, Copyright © frostybee.
See LICENSE for more information.