Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Sichere ProgrammierungWriting Native GPU Kernels in Rust with the CUDA-Rust Toolchain(01.10.2026 um 05:03 Uhr)
•
Sichere ProgrammierungSQL Window Functions Explained(01.10.2026 um 04:40 Uhr)
••••
Sichere ProgrammierungHi DEV! I’m Somya — Learning, Building & Figuring Things Out(01.10.2026 um 04:47 Uhr)
••••
Sichere ProgrammierungDeleting your AWS Copilot stacks can delete your database. Here's why.(01.10.2026 um 04:51 Uhr)
•
Sichere ProgrammierungWriting Native GPU Kernels in Rust with the CUDA-Rust Toolchain(01.10.2026 um 05:03 Uhr)
•
Sichere ProgrammierungSQL Window Functions Explained(01.10.2026 um 04:40 Uhr)
••••
Sichere ProgrammierungHi DEV! I’m Somya — Learning, Building & Figuring Things Out(01.10.2026 um 04:47 Uhr)
••••
Sichere ProgrammierungDeleting your AWS Copilot stacks can delete your database. Here's why.(01.10.2026 um 04:51 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

Dark Mode Screenshots in Docusaurus (That Actually Switch)

Docusaurus has dark mode built in. Your docs adapt. Your code blocks adapt. Your screenshots don't. You know the look - a crisp white UI screenshot glowing in…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

Docusaurus has dark mode built in. Your docs adapt. Your code blocks adapt.



Your screenshots don't.



You know the look - a crisp white UI screenshot glowing in the middle of someone's dark mode docs. Jarring.






The Workaround Nobody Wants to Do



You could maintain two versions of every screenshot. Light and dark. Then write custom React components to toggle between them based on color scheme. CSS media queries, theme context hooks, the works.



Or:




npm install heroshot









How It Works



Heroshot has a Docusaurus plugin that handles theme switching automatically. One component, zero JavaScript gymnastics.



Add the plugin to your config:




// docusaurus.config.js
const { heroshot } = require('heroshot/plugins/docusaurus');

module.exports = {
plugins: [heroshot()],
// ... rest of config
};






Use it in your MDX:




import { Heroshot } from 'heroshot/docusaurus';

# Getting Started

<Heroshot name="dashboard" alt="Dashboard overview" />






That's it. The component:




  • Finds both light and dark variants of your screenshot

  • Watches the Docusaurus theme toggle

  • Switches images instantly when someone clicks the moon icon

  • No page reload. No flash.






Setting Up Screenshots



First, capture them. Run the visual picker:




npx heroshot config






Start your Docusaurus dev server in another terminal. Navigate to it in the heroshot browser. Click elements you want to capture. Name them. Close when done.



Heroshot saves a config file. Then capture everything:




npx heroshot






This generates files like:




static/heroshots/dashboard-light.png
static/heroshots/dashboard-dark.png






Both variants captured automatically.






The Full Setup



Your project structure:




my-docs/
├── docs/
│ └── intro.mdx
├── static/
│ └── heroshots/ # screenshots go here
├── .heroshot/
│ └── config.json
└── docusaurus.config.js






Your heroshot config:




{
"outputDirectory": "static/heroshots",
"browser": {
"deviceScaleFactor": 2
},
"screenshots": []
}






The deviceScaleFactor: 2 gives you retina-quality images. Worth it for docs.






Multiple Viewports



Need mobile and desktop versions?




{
"name": "dashboard",
"url": "https://myapp.com/dashboard",
"viewports": ["mobile", "desktop"]
}






The component generates <picture> elements with media queries. Small screens see the mobile shot, large screens see desktop. Each with proper light/dark variants.






Updating Screenshots



UI changed? One command:




npx heroshot






Every screenshot regenerates. Both color schemes. All viewports. Your docs stay accurate.






How the Theme Detection Works



Docusaurus uses <html data-theme="dark"> when someone toggles dark mode. The component watches this attribute. Light screenshot shows by default, dark version swaps in when the theme changes.



Works with Docusaurus's built-in toggle. Works with any theme that follows the same pattern.






CI Integration



Add it to your build pipeline:




- run: npx heroshot
- run: npm run build






Screenshots update before every deploy. Documentation never goes stale.






heroshot - automatic screenshots for Docusaurus docs.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Dark Mode Screenshots in Docusaurus (That Actually Switch)

Thematisch verwandte Begriffe: Dark, Mode, Screenshots, Docusaurus · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag