Skip to content

tailwind no initial value in shadow root from content script #1585

@mengxi-ream

Description

@mengxi-ream

Describe the bug

Problem

I tried to add the utility .transform-x-full to a DOM element in content script but it does not work because className="transform-x-full" does not add the initial value normally, i.e. no following style in the css:

--tw-translate-z {
    syntax: "*";
    inherits: false;
    initial-value: 0;
}

--tw-translate-y {
    syntax: "*";
    inherits: false;
    initial-value: 0;
}

--tw-translate-x {
    syntax: "*";
    inherits: false;
    initial-value: 0;
}

What should happen

If you have className="transform-x-full", you will get the above initial-values which are generated by tailwind. For example, you can try the following code in Tailwind Playground

<div class="fixed top-0 right-0 z-[9998] h-full translate-x-1/2 transform bg-white shadow-xl transition-transform duration-300">123</div>

You will see

Image

What actually happened

But if you write something like the following in the index.tsx or App.tsx in content script, translate-x-full does not work because tw-translate-y is not defined (no initial-value)

      <div className="text-red-500 fixed top-0 right-0 z-[9998] h-full translate-x-full transform bg-zinc-700 shadow-xl transition-transform duration-300">
        123
      </div>

See the reproduction repo below for more detail

Popup works fine

Although transform-x-full does not work in content script but it works in popup. For example

<p className="read-the-docs translate-x-full">
        Click on the WXT and React logos to learn more
      </p>

Reproduction

https://github.com/mengxi-ream/tailwind-wxt-bug

Steps to reproduce

pnpm i and `pnpm dev

System Info

System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 172.53 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
    pnpm: 10.7.0 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
  Browsers:
    Chrome: 135.0.7049.96
    Safari: 18.2
  npmPackages:
    wxt: 0.20.0 => 0.20.0

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-triageSomeone (usually a maintainer) needs to look into this to see if it's a bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions