How to Style Contents in dangerouslySetInnerHTML with Tailwind

Perttu Lähteenlahti
1 min readJan 27, 2024

--

I recently needed to style the HTML content that was injected into an element using the dangerouslySetInnerHTML property. Since the other parts of the project were using Tailwind, I wanted to continue the same approach here instead of writing custom CSS for that part. Turns out Tailwind makes this relatively easy using the arbitrary variants. This allowed me to do the following:

--

--