Features
The Starlight Code Block Fullscreen plugin enhances your documentation experience by providing fullscreen functionality for code blocks.
How it works?
Section titled “How it works?”- The plugin automatically detects and enhances all Expressive Code blocks on your pages,
- The fullscreen overlay adapts to your page’s background color for seamless integration,
- You can customize the fullscreen button icons by providing your own SVG paths,
- Animation duration is validated and constrained to ensure optimal performance (150-700ms),
- Focus management ensures accessibility compliance with proper keyboard navigation.
Fullscreen Mode
Section titled “Fullscreen Mode”Transform any code block into a distraction-free fullscreen view with a single click. The fullscreen mode provides:
- Enhanced readability: Code blocks expand to fill the entire screen,
- Dark overlay: Minimizes distractions with a semi-transparent background,
- Optimized zoom: Automatically applies configurable zoom levels for better code visibility.
// This code block will have a fullscreen buttonfunction greetUser(name) { console.log(`Hello, ${name}!`); return `Welcome to the documentation`;}
Usage Examples
Section titled “Usage Examples”Basic Navigation
Section titled “Basic Navigation”- Focus a code block: Use TAB to navigate to any code block on the page,
- Enter fullscreen: Press Enter or click the fullscreen button,
- Navigate in fullscreen: Use TAB to move through the code content,
- Exit fullscreen: Press Escape, use the back button, or click the exit button.
Multi-Block Navigation
Section titled “Multi-Block Navigation”- Cycle through blocks: Use TAB to move between different code blocks,
- Quick activation: Press Enter on any focused code block to enter fullscreen,
- Seamless switching: Exit one block and immediately navigate to another.
State Management
Section titled “State Management”The plugin provides advanced state management to ensure a reliable user experience:
- Session persistence: Remembers user preferences during the session using localStorage,
- Scroll position: Automatically saves and restores scroll position when exiting fullscreen,
- History integration: Proper browser history management for back button support,
- Focus state management: Maintains focus context and provides proper focus restoration for accessibility.
⌨️ Keyboard Navigation
Section titled “⌨️ Keyboard Navigation”The plugin provides comprehensive keyboard support for enhanced accessibility and user experience:
Fullscreen Controls
Section titled “Fullscreen Controls”- Escape key: Quickly exit fullscreen mode (configurable),
- Browser back button: Use your browser’s back button to exit fullscreen (configurable),
- Tab navigation: Full keyboard navigation support within fullscreen mode.
Code Block Cycling
Section titled “Code Block Cycling”Navigate between multiple code blocks on the same page using keyboard shortcuts:
- TAB Key: Cycle forward through all code blocks with fullscreen buttons on the current page,
- Enter Key: Activate the fullscreen mode for the currently focused code block,
- Shift + TAB: Cycle backward through code blocks (standard browser behavior).
This feature is particularly useful when you have multiple code examples and want to quickly navigate between them without using the mouse.