Skip to content

feat(wxt-demo): add rem-to-px postcss example for Shadow Root UI#2333

Open
Aniket-lodh wants to merge 5 commits intowxt-dev:mainfrom
Aniket-lodh:feat/wxt-demo-rem-fix-example
Open

feat(wxt-demo): add rem-to-px postcss example for Shadow Root UI#2333
Aniket-lodh wants to merge 5 commits intowxt-dev:mainfrom
Aniket-lodh:feat/wxt-demo-rem-fix-example

Conversation

@Aniket-lodh
Copy link
Copy Markdown

Overview

Adds a rem-fix.content example to wxt-demo that demonstrates how to use postcss-rem-to-responsive-pixel to convert rem units to px at build time inside a createShadowRootUi content script.

This prevents host page font-size overrides (e.g., Reddit's font-size: 10px on <html>) from breaking the extension UI's sizing inside the Shadow DOM.

Manual Testing

  1. Run bun install then bun run --filter wxt-demo dev
  2. Visit any website — the demo card should appear at the top of the page
  3. Visit a site that overrides root font-size (e.g., Reddit) — the card should render at the same size as on other sites
  4. Inspect the Shadow Root's CSS — confirm all rem values have been converted to px

Related Issue

Follow-up to #2330 (docs: add warning about rem unit inheritance in Shadow Root UI), as requested by @PatrykKuniczak.

This PR addresses #678

@Aniket-lodh Aniket-lodh requested a review from aklinker1 as a code owner May 3, 2026 13:30
@netlify
Copy link
Copy Markdown

netlify Bot commented May 3, 2026

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 3468f50
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/69fc0131edb27700088760ff
😎 Deploy Preview https://deploy-preview-2333--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.

@github-actions github-actions Bot added the pkg/wxt-demo Includes changes to the `packages/wxt-demo` directory label May 3, 2026
Copy link
Copy Markdown
Collaborator

@PatrykKuniczak PatrykKuniczak left a comment

Choose a reason for hiding this comment

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

Works well, a couple of changes needed 😄

Comment thread packages/wxt-demo/src/entrypoints/rem-fix.content/index.ts Outdated
Comment thread packages/wxt-demo/src/entrypoints/rem-fix.content/style.css
Aniket-lodh and others added 2 commits May 4, 2026 19:37
Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
@Aniket-lodh
Copy link
Copy Markdown
Author

@PatrykKuniczak Done. Do tell me if anything else is needed

@Aniket-lodh Aniket-lodh requested a review from PatrykKuniczak May 4, 2026 14:20
@PatrykKuniczak
Copy link
Copy Markdown
Collaborator

@Aniket-lodh I've reviewed your second PR.
I'll take a look on your new changes after gym.

Comment thread packages/wxt-demo/src/entrypoints/rem-fix.content/index.ts Outdated
Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
@Aniket-lodh Aniket-lodh requested a review from PatrykKuniczak May 7, 2026 03:25
Comment on lines +21 to +22
desc.textContent = `This UI uses 'rem' units in CSS, converted to 'px' at build time by 'postcss-rem-to-responsive-pixel'.
It will render at the same size regardless of the host pages root 'font-size'.`;
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.

Run prettier, because that line isn't formatted properly.

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

Labels

pkg/wxt-demo Includes changes to the `packages/wxt-demo` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants