fix: prevent code blocks flash in dark mode (AI-assisted)#11967
fix: prevent code blocks flash in dark mode (AI-assisted)#11967titojuanc wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Hi @titojuanc! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Pre-flight checklist
Motivation
Fixes #11566
When loading a Docusaurus page in dark mode, code blocks briefly flash with light theme colors before switching to the correct dark theme. This happens because Prism theme colors were applied as inline styles via JavaScript, which only take effect after React hydration.
This PR injects CSS variables for both light and dark Prism themes directly in a <style> tag in the , leveraging the [data-theme] attribute that is already set by a blocking script. This ensures code blocks display with the correct background color from the very first paint, without waiting for hydration.
Test Plan
(AI-assisted)
Test links
Related issues/PRs
Closes #11566