vincent15000's avatar

TailwindCSS typography and Tiptap editor

Hello,

I have this string generated by Tiptap.

<p>ceci <span style="color:rgb(255,0,0);">est </span><span style="color:rgb(255,0,0);"><strong>un test</strong></span></p>

un test is in bold and in black instead of being in bold and in red.

It seems to be a problem with TailwindCSS typography plugin.

I have tried to force inheriting the color for the strong tag directly in tailwind.config.js, but it doesn't change anything.

strong: {
    color: 'inherit',
},

Do you have any idea how to solve this problem ?

Thanks for your help.

V

0 likes
2 replies
LaryAI's avatar
Level 58

You're running into a common issue with Tailwind CSS's Typography plugin (also known as @tailwindcss/typography or the "prose" class). By default, the plugin applies its own styles to tags like <strong> inside your content—including setting their color to the current text color, which overrides custom inline styles (such as your Tiptap output).

The Problem:
.prose sets color on <strong> (and <b>) to inherit, which means the color value from the <span> style is not taking effect as expected.

Solution 1: Override the Typography Styles with Custom CSS

You need to ensure that <strong> and <b> tags inside spans with a style actually inherit the color from the span instead of being reset by the Typography plugin.

Add this CSS to your project:

.prose span[style] strong,
.prose span[style] b {
  color: inherit !important;
}
  • This selector ensures that if a <strong> or <b> is inside a styled span, it will inherit the color from that span, instead of being overridden by the prose styles.
  • The !important is necessary because the prose plugin adds fairly specific rules.

Solution 2: Tailwind Config (More Complex, Less Direct)

You can extend the Typography plugin's theme in your tailwind.config.js, but it's tricky because the plugin targets elements globally, and not based on parent/child relationships.

A Tailwind config approach is not enough here—the above CSS override is much more reliable.

Apply the Fix

  1. Create a CSS file (e.g., resources/css/overrides.css) if you don't have one.
  2. Add the above CSS code to it.
  3. Make sure it's imported after your Tailwind CSS styles, so it overrides them.

Example

Supposing your Tiptap output is rendered like this:

<div class="prose">
  <p>ceci <span style="color:rgb(255,0,0);">est </span>
    <span style="color:rgb(255,0,0);"><strong>un test</strong></span>
  </p>
</div>

After applying the CSS override, “un test” should correctly appear bold and red.


Summary:
The correct and most future-proof fix is to selectively override the prose styles for strong/b inside styled spans as shown above.

Let me know if you need a live example or further tweaks!

Please or to participate in this conversation.