To use Astro Tailwind Typography, install @tailwindcss/typography, register it with @plugin in your Tailwind CSS file, and wrap your rendered Markdown in an element with the prose class. Headings, lists, links, tables, quotes and code blocks in that element get readable defaults without writing a single selector.
Key Takeaways
- Tailwind’s preflight strips default styles from headings and lists, which is why raw Markdown looks flat.
proserestores them inside one wrapper, so the rest of your layout is untouched.- Tailwind 4 loads the plugin from CSS with
@plugin; Tailwind 3 uses thepluginsarray in the config.dark:prose-inverthandles dark mode, andprose-*modifiers tune individual elements.
Install the plugin
This assumes Tailwind 4 is already set up through npx astro add tailwind (see our Tailwind CSS setup guide).
npm install -D @tailwindcss/typography
Register it in the stylesheet that imports Tailwind:
/* src/styles/global.css */
@import 'tailwindcss';
@plugin '@tailwindcss/typography';
On a Tailwind 3 project, add it to the config instead:
// tailwind.config.mjs (Tailwind CSS 3)
import typography from '@tailwindcss/typography';
export default {
content: ['./src/**/*.{astro,md,mdx,ts}'],
plugins: [typography],
};
Wrap your rendered content
Apply prose to the element that holds the Markdown output, not to the whole page:
---
// src/pages/blog/[id].astro
import { getCollection, render } from 'astro:content';
import Layout from '../../layouts/Layout.astro';
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => ({ params: { id: post.id }, props: { post } }));
}
const { post } = Astro.props;
const { Content } = await render(post);
---
<Layout title={post.data.title}>
<h1 class="text-4xl font-bold">{post.data.title}</h1>
<article class="prose prose-lg dark:prose-invert max-w-none">
<Content />
</article>
</Layout>
prose caps line length at about 65 characters by default. Keep that for reading comfort, or add max-w-none when the parent already sets a width. Size modifiers (prose-sm, prose-lg, prose-xl) scale the whole type ramp together.
Tune individual elements
Element modifiers target tags inside the prose block without custom CSS:
<article class="prose prose-a:text-teal-700 prose-a:no-underline hover:prose-a:underline prose-headings:font-semibold prose-img:rounded-lg prose-code:before:content-none prose-code:after:content-none">
The last two remove the backticks the plugin adds around inline code, a common request. For brand colors, pick a gray scale with prose-slate, prose-zinc or prose-stone, or override the plugin’s CSS variables:
/* src/styles/global.css */
@layer components {
.prose {
--tw-prose-links: var(--color-teal-700);
--tw-prose-headings: var(--color-slate-900);
}
}
Opt out inside prose
Components you embed in MDX (a callout, a pricing card) inherit prose styles too. Add not-prose to their root element to switch the typography styles off for that subtree:
---
// src/components/Callout.astro
---
<aside class="not-prose rounded-lg border p-4">
<slot />
</aside>
Code blocks
Astro highlights code with Shiki at build time and sets inline background colors. prose adds its own pre background and padding, which can clash. Either keep Shiki’s colors and remove the plugin’s background with prose-pre:bg-transparent, or switch Shiki to a theme that matches. Our Shiki syntax highlighting guide covers the theme options, and the official plugin README lists every modifier.
Our blog and editorial themes ship with article styling already in place, and the theme styling docs show where those styles live.
FAQ
Why does my Markdown have no styling in Astro with Tailwind?
Tailwind’s preflight resets margins, font sizes and list styles on every element. Markdown output is plain HTML, so it renders flat. Wrapping it in prose restores readable defaults for that block only.
Does Tailwind Typography work with MDX in Astro?
Yes. MDX renders to HTML like Markdown, so the prose wrapper styles it the same way. Use not-prose on embedded components that should keep their own styles.
How do I use Tailwind Typography in dark mode?
Add dark:prose-invert next to prose. It swaps the plugin’s color variables to a light-on-dark palette whenever your dark variant is active.