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
Browse and select components interactively:
npm run swizzleThis will prompt you to:
See all swizzlable components from a theme:
npm run swizzle @docusaurus/theme-classic -- --listWrap a component to add customizations while keeping the original:
npm run swizzle @docusaurus/theme-classic ComponentName -- --wrapWhen to use wrap:
Eject to fully replace and customize a component:
npm run swizzle @docusaurus/theme-classic ComponentName -- --ejectWhen to use eject:
--wrap - Safe swizzle mode (wraps original component)--eject - Unsafe swizzle mode (copies full source)--list - List all available components to swizzle--typescript - Generate TypeScript files (default)--javascript - Generate JavaScript filesAfter swizzling, components are created in:
src/theme/ComponentName/ - Directory-based components (with index.tsx)src/theme/ComponentName.tsx - Single-file componentsnpm run swizzle @docusaurus/theme-classic Footer -- --ejectAfter running this, edit the footer in src/theme/Footer/index.tsx.
npm run swizzle @docusaurus/theme-classic Navbar -- --wrapThis creates a wrapper in src/theme/Navbar/index.tsx that imports and extends the original.
# First, see what's available
npm run swizzle @docusaurus/theme-classic -- --list
# Then swizzle the component you need
npm run swizzle @docusaurus/theme-classic DocItem -- --wrapComponent not found:
--list to see available componentsTypeScript errors after swizzling:
Changes not appearing:
.docusaurus cache: npm run clear