Parse classNames to inline styles.
See original GitHub issueIt would be nice if we could use the server side rendering part, to style emails with this library.
The thing is, not all mail clients know how to handle style tags. The recommended approach is still to use inline styles (<div style="color: red">
).
I do realize that it’s not possible to support everything with that approach, but even partial support could be of immense value when creating mail templates.
Things that are unsupported (like media queries) could still go to the head style sheet for those clients that do support it.
It would also mean that css variables should be resolved.
Thoughts?
Issue Analytics
- State:
- Created 3 years ago
- Comments:14
Top Results From Across the Web
Replacing class styles with inline styles - Stack Overflow
I have svg image, that has some classes(jointJS paper). I'm saving this svg, and then converting it to png file on backend. Problem...
Read more >Style React Components with className and inline Styles
In this lesson we'll explore the className and style prop for styling our components. This lesson goes much deeper than that.
Read more >Inline Styling with React - Pluralsight
To use inline styles in React, use the style attribute, ... In most cases, className should be used to reference classes defined in...
Read more >How to use styles in React: Inline styles, CSS Modules ...
Let's start with inline styles. Inline styles are used when a single HTML element needs unique styles. Whenever there is more than one...
Read more >html-react-parser - npm
The reason why your HTML attributes aren't getting called is because inline event handlers (e.g., onclick ) are parsed as a string rather...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mattrossman That makes things easier for us.
Something like the following should work already:
Based on a react app:
If this works it is an extension to the existing SSR examples (incl the shim) as only the last line is specific to email. We could add a recipe or ad it to the FAQs.
That’s kind of what I figured. The
style
function proposed by @sastan seems like a nice, easy way to get a limited version of Twind via inline styles. I can’t imagine it could get much easier than this:I’m sure there are a plenty of considerations and challenges that I haven’t thought of but it seems like a neat idea.