Skip to content

fix(theme-classic): improve code block Copy/word-wrap button contrast (#10821)#12279

Open
gunjanjaswal wants to merge 1 commit into
facebook:mainfrom
gunjanjaswal:fix/10821-code-block-button-contrast
Open

fix(theme-classic): improve code block Copy/word-wrap button contrast (#10821)#12279
gunjanjaswal wants to merge 1 commit into
facebook:mainfrom
gunjanjaswal:fix/10821-code-block-button-contrast

Conversation

@gunjanjaswal

Copy link
Copy Markdown
Contributor

Motivation

The "Copy" and "Toggle word wrap" buttons on code blocks are hard to see in the default classic theme. On hover they render at opacity: 0.4 over a background that matches the code area, so the code behind them shows through and the icons nearly vanish, especially over busy lines. That's #10821, where the low contrast was confirmed and an opaque background was suggested.

Fix

In CodeBlock/Buttons/styles.module.css:

  • The buttons now use an opaque, neutral background (--ifm-color-emphasis-200) instead of the semi-transparent code-area color, so they read as a distinct chip instead of blending in.
  • A slightly stronger border (--ifm-color-emphasis-400) for a clearer edge.
  • On code-block hover the buttons are fully opaque (opacity: 1) instead of 0.4, so the code no longer shows through them.
  • Direct hover/focus darkens the button to --ifm-color-emphasis-300 for clearer feedback.

It all uses existing Infima tokens, so it adapts to light and dark themes and to custom theme colors without any hardcoded values. The buttons are still hidden at rest and only appear when you hover the code block, so nothing changes except that they are now legible.

Closes #10821

…n hover

The copy and word-wrap buttons on code blocks used a semi-transparent
background (opacity 0.4) tinted with the code area's own color, so on
hover the code behind them showed through and the icons were barely
visible. Give the buttons an opaque neutral background and a slightly
stronger border, and show them fully opaque on hover, so they read
clearly in both light and dark themes.

Closes facebook#10821
@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Jul 13, 2026
@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 43fbfb5
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a5447679dca9b00088b4160
😎 Deploy Preview https://deploy-preview-12279--docusaurus-2.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toggle word wrap and Copy buttons in code examples almost invisible

1 participant