Skip to content

Update code block styling and syntax theme colors#5109

Merged
huntie merged 1 commit into
react:mainfrom
huntie:update-code-block-styling
Jun 3, 2026
Merged

Update code block styling and syntax theme colors#5109
huntie merged 1 commit into
react:mainfrom
huntie:update-code-block-styling

Conversation

@huntie

@huntie huntie commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

Modernise apperance of code blocks by updating font, tweaking sizing, and introducing light/dark variants (aligned with react.dev).

Changes

  • Remove the custom Source Code Pro web font in favor of the default Docusaurus system monospace font stack (bonus: no custom font download).
  • Add separate light and dark Prism syntax themes aligned to the react.dev Sandpack color palette, replacing the previous single dark-only custom theme.
  • Reduce code block font size and increase line height.
  • Update code block title backgrounds to match their code block, with a keyline separator.

Syntax colors source: https://github.com/reactjs/react.dev/blob/6ec61348646040795fdaa9de14a9bec603260f87/src/styles/sandpack.css#L38-L78

Notes

The main motivation here is horizontal space efficiency, which I felt was poor with Source Code Pro.

Screenshot 2026-06-03 at 14 05 02

Test plan

Before

Light Dark
file-70f1a6e09edb95899722086196de927e file-bb93ada1f7c92b2f889685e60c6df4d7

After

Light Dark
file-0e4c3a2eae7ba1465cf7a675717ebbe0 file-37271875d08532e756bc950f7f0c0891

@huntie huntie requested a review from Simek June 3, 2026 13:07
@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown

@huntie is attempting to deploy a commit to the React Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@netlify

netlify Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit db7561a
🔍 Latest deploy log https://app.netlify.com/projects/react-native/deploys/6a203eab7ec0ed00089a3c7a
😎 Deploy Preview https://deploy-preview-5109--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@huntie huntie force-pushed the update-code-block-styling branch from dc7a639 to 4f40608 Compare June 3, 2026 13:12
@Simek

Simek commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

This looks good, great changes overall! 👍

Just one thing which we might want to address - the light mode code blocks lacks a bit of separation now from the background after the changes. To fix that we can add slight box shadow (like on react.dev) or just use border.

Screenshot 2026-06-03 155143

@huntie

huntie commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

@Simek I reckon this is enough contrast. Not keen on the visual clutter of shadows.

I guess we could try an outline too, matching the admonitions (previewed below).

image

The main thing that matters I'd say is the text contrast (vs contrast with surrounding paragraphs).

Edit: This also matches the homepage graphic more closely, actioning.

image

Modernise apperance of code blocks by updating font, tweaking sizing, and introducing light/dark variants (aligned with react.dev).

**Changes**

- Remove the custom Source Code Pro web font in favor of the default Docusaurus system monospace font stack.
- Add separate light and dark Prism syntax themes aligned to the react.dev Sandpack color palette, replacing the previous single dark-only custom theme.
- Reduce code block font size and increase line height.
- Update code block title backgrounds to match their code block, with a keyline separator.

Syntax colors source: https://github.com/reactjs/react.dev/blob/6ec61348646040795fdaa9de14a9bec603260f87/src/styles/sandpack.css#L38-L78
@huntie huntie force-pushed the update-code-block-styling branch from 4f40608 to db7561a Compare June 3, 2026 14:48

@Simek Simek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, and border adds enough of separation. Thanks for the quick update! 🚀

@huntie huntie merged commit bf18e60 into react:main Jun 3, 2026
6 of 7 checks passed
@huntie huntie deleted the update-code-block-styling branch June 3, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants