I think I found a bug in Tailwind CLI with this custom variant. When I use the --minify flag, the "@container style(){...}" is removed from the output.

--minify does minify + optimize and the optimize mechanism is the one who removes the code.

Don't know why, but the CLI has barely any docs.
Reposted from Marius Vatasoiu
This is the solution for dark mode with Tailwind & Web Components.

The first selector is for Light DOM - works with every major browser.

The second selector is for Shadow DOM - Works Chrome 105 and Safari 18. Firefox soon 🤞

Comments