In tailwind 4 you only need to do the following. Install the plugin
npm install -D @tailwindcss/typography
enable it in global.css (assuming you are using default next configuration withapp router):
@import "tailwindcss";
@plugin '@tailwindcss/typography';
Github issue dicussing this
Answer from Iaroslav Sobolev on Stack OverflowIn tailwind 4 you only need to do the following. Install the plugin
npm install -D @tailwindcss/typography
enable it in global.css (assuming you are using default next configuration withapp router):
@import "tailwindcss";
@plugin '@tailwindcss/typography';
Github issue dicussing this
Update (configure without tailwind.config.js)
I just based it on an answer written by someone else. I quickly put together a v4 reproduction in the Play environment without a config file by new @utility directive:
- Tailwind Play Reproduction
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@utility prose-pink {
@apply prose;
& > * {
--tw-prose-body: var(--color-pink-800);
--tw-prose-headings: var(--color-pink-900);
}
}
With this, I produce exactly the same result that the documentation recommends using a config file for:
- Adding custom color theme for Typography
Plugin
Starting from TailwindCSS v4, a CSS-first configuration approach is preferred. Therefore, all plugins should be integrated with TailwindCSS using the @plugin directive. Following the Typography documentation:
- New CSS-first configuration option in v4 - StackOverflow
@plugindirective - TailwindCSS v4 Docs- Typography Installation - GitHub Readme
npm install -D @tailwindcss/typography
@import "tailwindcss";
@plugin "@tailwindcss/typography";
Configuration
In CSS-first mode, you have the option to change the default prose class name when declaring the plugin:
@import "tailwindcss";
@plugin "@tailwindcss/typography" {
className: wysiwyg; /* changed from prose to wysiwyg */
}
In TailwindCSS v3, however, the legacy JavaScript-based configuration (tailwind.config.js) allowed for custom configuration as well.
You can still do this using the @config directive.
@configdirective - TailwindCSS v4 Docs- Adding custom color themes to Typography - GitHub Readme
- Customizing the CSS to Typography - GitHub Readme
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@config "./relative/path/to/tailwind.config.js";
/** @type {import('tailwindcss').Config} */
module.exports = {
theme: {
extend: {
typography: () => ({
// ...
}),
},
},
}
Contrary to the documentation, by completely omitting the JavaScript-based configuration, you still have the option to customize the prose utility like this:
- Typography upgrade to TailwindCSS v4 - @ErwannRousseau's code snippet - GitHub
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@utility prose {
--tw-prose-body: var(--color-primary);
--tw-prose-headings: var(--color-primary);
--tw-prose-bold: var(--color-primary);
--tw-prose-quote-borders: var(--color-slate-300);
--tw-prose-quotes: var(--color-muted-foreground);
--tw-prose-code: var(--color-primary);
code {
&::before,
&::after {
display: none;
}
text-wrap: nowrap;
}
blockquote {
font-weight: 400;
}
}
V0, Tailwind 4, Next 16, the perfect storm for typography
How to Configure Font Styles with @theme in Tailwind CSS v4 - Stack Overflow
Tailwind v4 plugin configuration: how to override 65ch max-width in Tailwind CSS Typography - Stack Overflow
Tailwind v4 Typography Plugin + Custom Colors, not working?
Videos
Since Tailwind v4 does not support plugins yet, Is there any work around to get the Typography plugin work?
Typography plugin is working, but want custom color theme, so following this:
https://github.com/tailwindlabs/tailwindcss-typography?tab=readme-ov-file#adding-custom-color-themes
I did exactly this, except replace everything with "brand" instead of "pink".
Still default colors.
I'm really confused on how the font and text work in Tailwind 4.
According to the docs, "Use the --font-* theme variables to customize the font family utilities in your project:"
@theme { --font-hello: "Oswald", "sans-serif"; }
Then it's used as:
<div class="font-hello"> <!-- ... --> </div>
Now, how in the world would I then set the font-weight to this "custom" font? According to the docs custom font-weights are defined like this:
@theme { --font-weight-hello: 900; }
And used as:
<div class="font-hello"> <!-- ... --> </div>
But this will not work as the "--font-hello" class override any properties for the "font-hello" class. If I however remove the "--font-hello" from the theme then the "--font-weight-hello" works and the "font-hello" class has the font-weight property.
I really feel like some of the things in v4 is a mess. Of course it could be me but its not that intutive to create custom classes in nice and structred way. This is also true regadring the "text" properties.
In this case, according to the docs, I would expect to be able to write the theme like this:
@theme { --font-body: "Some Font"; --font-weight-body: 700; }
And then used as below, with both the font-family and the font-weight properties within the "font-body" class, but this does not work because they conflict with each other.
<div class="font-body"> <!-- ... --> </div>