Use when swizzling Docusaurus theme components and editing theme elements — wrap or eject components from @docusaurus/theme-classic, override navbar/footer/sidebar/TOC/DocItem, place customised components under src/theme/, and choose safe (--wrap) vs full (--eject) swizzles. Triggers on tasks involving Docusaurus swizzling, theme component customization, navbar, footer, sidebar, or layout modifications.
77
97%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Passed
No known issues
Path: src/theme/Footer/
Use case: Customize footer content, links, copyright, social media icons
Example customization:
import React from 'react';
import Footer from '@theme-original/Footer';
export default function FooterWrapper(props) {
return (
<>
<Footer {...props} />
<div className="custom-footer-section">
{/* Add custom footer content */}
</div>
</>
);
}Path: src/theme/Navbar/
Use case: Modify navigation bar appearance, add custom elements, change behavior
Common modifications:
Path: src/theme/Layout/
Use case: Wrap all pages with custom providers, analytics, or global components
Path: src/theme/DocItem/
Use case: Customize documentation page layout, add custom elements to doc pages
Common modifications:
Path: src/theme/DocSidebar/
Use case: Adjust sidebar behavior, styling, and interaction
Common modifications:
Path: src/theme/TOC/
Use case: Modify table of contents display, add custom elements
Common modifications:
Path: src/theme/BlogPostPage/
Use case: Customize blog post layout and structure
Path: src/theme/BlogListPage/
Use case: Modify blog list view, pagination, filtering
Path: src/theme/CodeBlock/
Use case: Customize code block rendering, add features like copy button customization
Path: src/theme/MDXComponents/
Use case: Override or extend default MDX components used in markdown
Docusaurus marks components with safety levels:
Check safety level:
npm run swizzle @docusaurus/theme-classic -- --listComponents are marked with their safety level in the list output.
Understanding component relationships helps you choose what to swizzle:
Layout (top-level wrapper)
├── Navbar
├── DocPage
│ ├── DocSidebar
│ └── DocItem
│ └── TOC
└── FooterTip: Swizzle at the lowest level that meets your needs to minimize maintenance burden.
Component: Layout Mode: Wrap Why: Wrapping Layout lets you add providers without replacing core functionality
Component: Footer Mode: Eject Why: Significant design changes usually require full control
Component: DocItem Mode: Wrap Why: Can inject custom elements without modifying core doc rendering
Component: CodeBlock Mode: Eject Why: Deep integration with highlighting engine requires full access