Tailwind CSS v4 Breaks Markdown Formatting with react-markdown #17645
Unanswered
VismayRBGowda
asked this question in
Help
Replies: 1 comment 2 replies
-
You could consider:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using Tailwind CSS v4 in a React project with react-markdown, the default markdown formatting (e.g., headings, lists) does not render correctly — styles appear to be completely stripped.
Steps to Reproduce:
Create a new React project using Vite or Create React App.
Install the following packages:
npm install react-markdown
Add the Tailwind import to index.css:
@import "tailwindcss";
Use react-markdown to render some sample markdown content (e.g. # Heading, * List item).
Observe the rendered output — markdown formatting will be missing.
Expected Behavior:
Markdown content should be correctly rendered with semantic HTML styled appropriately or left untouched by Tailwind’s preflight.
Actual Behavior:
The markdown content renders, but with no visible formatting. Headings, lists, and other block elements appear unstyled or inline — likely due to Tailwind's preflight reset in v4.
Code Samples:
index.css:
@import "tailwindcss";
Home.jsx:
import React from 'react';
import ReactMarkdown from 'react-markdown';
function Home() {
return (
{
# Test Heading\n* Test List Item
});
}
export default Home;
vite.config.js (if using Vite):
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
})
Environment:
Tailwind CSS: v4.x
"dependencies": {
"@tailwindcss/vite": "^4.1.3",
"markdown-vite-test": "file:",
"react": "^19.0.0",
"react-dom": "^19.0.0",
}
Build tool: Vite
Additional Context:
Removing Tailwind entirely restores correct markdown rendering.
Overriding or customizing @tailwind base partially helps, but isn't ideal.
Appears to be caused by Tailwind's preflight reset conflicting with semantic elements rendered by react-markdown.
Beta Was this translation helpful? Give feedback.
All reactions