Skip to content

docs: add warning about rem unit inheritance in Shadow Root UI#2330

Open
Aniket-lodh wants to merge 1 commit intowxt-dev:mainfrom
Aniket-lodh:docs/shadow-root-rem-inheritance
Open

docs: add warning about rem unit inheritance in Shadow Root UI#2330
Aniket-lodh wants to merge 1 commit intowxt-dev:mainfrom
Aniket-lodh:docs/shadow-root-rem-inheritance

Conversation

@Aniket-lodh
Copy link
Copy Markdown

Overview

When using createShadowRootUi, the Shadow DOM isolates most CSS from the host page. However, rem units are not isolated because they are relative to the root <html> element's font-size, which lives outside the Shadow Root. If the host website sets a custom font-size on <html> (e.g., Reddit uses font-size: 10px), all rem-based styles inside the Shadow Root will scale incorrectly — making the extension UI appear too large or too small depending on the site.

WXT v0.20+ added all: initial to reset inherited properties, and the upgrade guide already mentions that rem units are not affected. However, this warning is buried in the upgrade docs and not discoverable by users reading the content scripts guide — which is where most developers go to learn about createShadowRootUi.

This PR adds:

  1. A :::warning block in the Shadow Root section of the Content Scripts guide explaining the rem inheritance edge case, with a concrete fix using postcss-rem-to-responsive-pixel — including PostCSS config examples for both ESM and CJS setups with Tailwind CSS integration.
  2. A new FAQ entry: "My content script UI looks too big or too small on certain websites" — with a brief explanation and a link to the full solution in the content scripts guide.

Manual Testing

  1. Run bun run docs:dev
  2. Navigate to /guide/essentials/content-scripts → scroll to the Shadow Root section → verify the warning block renders correctly after the example links, with working code-group tabs (ESM/CJS)
  3. Navigate to /guide/resources/faq → verify the new entry appears in the table of contents and the internal link to the content scripts guide works
  4. Confirm no other files were modified (git diff --name-only should only show docs/guide/essentials/content-scripts.md and docs/guide/resources/faq.md)

Related Issue

This PR addresses #678

@Aniket-lodh Aniket-lodh requested a review from aklinker1 as a code owner May 2, 2026 16:59
@netlify
Copy link
Copy Markdown

netlify Bot commented May 2, 2026

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 074d7ad
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/69f62d6a6ad53000086c1aab
😎 Deploy Preview https://deploy-preview-2330--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@PatrykKuniczak
Copy link
Copy Markdown
Collaborator

PatrykKuniczak commented May 3, 2026

@Aniket-lodh Are you able to add example on wxt-demo ?
You can use mentioned third party package.
If you can, that would be perfect :)

But let's do it in other PR and link this one as a "base".

@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.67%. Comparing base (e75e534) to head (074d7ad).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2330      +/-   ##
==========================================
- Coverage   79.73%   79.67%   -0.06%     
==========================================
  Files         131      131              
  Lines        3804     3804              
  Branches      861      861              
==========================================
- Hits         3033     3031       -2     
- Misses        686      688       +2     
  Partials       85       85              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 3, 2026

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@2330

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@2330

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@2330

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@2330

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2330

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@2330

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@2330

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@2330

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@2330

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@2330

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@2330

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@2330

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@2330

wxt

npm i https://pkg.pr.new/wxt@2330

commit: 074d7ad

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants