question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

twind (next) SSR versions not parsing pseudo selectors

See original GitHub issue

Hey there! I was doing some testing in both SSR (Remix) and client-side locally and noticed pseudo selectors like ::before are not being parsed correctly:

Remix example

https://codesandbox.io/s/cool-dawn-r8gm4?file=/app/routes/index.tsx

In app/routes/index.tsx I’ve added before:content-['test'] but it’s not showing up next to the title

Client side example

https://codesandbox.io/s/ancient-thunder-uidxu

In index.html I’ve added before:content-['test'] and it shows up correctly next to the title.


Is this potentially something to do with the inline function? The VS Code extension (which I think I remember reading elsewhere that it needs to be updated) is parsing this as:

before:content-['*']
.before\:content-\[\'\*\'\]:before{align-content:['*']}

So this may be unrelated, but wanted to mention that as well. Are there any examples of using SSR with the “library” mode; as I’m curious if the inline function would be used in that case. Thanks as always!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sastancommented, Feb 16, 2022

If you don’t want to process class names than do not call consume. Only use stringify.

1reaction
danielweckcommented, Feb 15, 2022

For what it’s worth, I tested this edge case in my Preact app using JSX class="before:content-['*']" as well as class={"before:content-['*']"}, no problems:

.before\:content-\[\'*\'\]:before{--tw-content:"*";content:var(--tw-content)}

Mind you, this is with Preact WMR so the JSX is compiled to htm, then executed at pre-rendering time (SSG) through my custom Preact options.vnode() interceptor … so quite a different dataflow to Remix SSR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extended Functionality - Twind
Most pseudo classes can be used as variant or group-* variant. Unknown variants (not listed in core variants) are assumed to be pseudo...
Read more >
Problems surrounding SSR injection of <style> and ... - GitHub
Another suggested workaround is to somehow replace :first-child selectors with :first-child:not(style), style:first-child + * in the styles ...
Read more >
Next.js is not rendering CSS in Server Side Rendering
js application using npx create-next-app and have not made any changes to it. I noticed that imported .css styles are being rendered properly...
Read more >
Build a Full Stack App with Next.js, Tailwind, tRPC and Prisma ...
Let's setup next.js and navigate into the project directory: npx create-next-app@latest --ts grocery-list cd grocery-list.
Read more >
Pseudo-elements - CSS: Cascading Style Sheets | MDN
A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found