Skip to content

Code blocks flashes in dark mode #11566

@carolyn-sun

Description

@carolyn-sun

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

When loading a Docusaurus page in dark mode, code blocks briefly flash with light theme colours before switching to the correct dark theme colours. This creates a jarring visual experience.

Reproducible demo

Can reproduce on any official page, https://docusaurus.io/docs/configuration

Steps to reproduce

  1. Configure Docusaurus with both light and dark Prism themes.
prism: {
  theme: prismThemes.oneLight,
  darkTheme: prismThemes.oneDark,
},
  1. Switch the site to dark mode
  2. Navigate to any page with code blocks
  3. Observe the code blocks during loading

Expected behavior

Code blocks should immediately display with the dark theme colours when the page loads in dark mode.

Actual behavior

Code blocks briefly display with light theme colours (a white background and light syntax highlighting), then quickly switch to dark theme colours. This flash is very noticeable and disrupts the user experience.

Your environment

N/A

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionexternalThis issue is caused by an external dependency and not Docusaurus.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions