Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tailwindcss/typography

tailwindlabs6.5mMIT0.5.16TypeScript support: included

A Tailwind CSS plugin for automatically styling plain HTML content with beautiful typographic defaults.

readme

<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-light.svg"> Tailwind CSS Typography </picture>

The official Tailwind CSS Typography plugin provides a set of prose classes you can use to add beautiful typographic defaults to any vanilla HTML you don’t control, like HTML rendered from Markdown, or pulled from a CMS.

<article class="prose lg:prose-xl">{{ markdown }}</article>

To see what it looks like in action, check out our live demo on Tailwind Play.


Installation

Install the plugin from npm:

npm install -D @tailwindcss/typography

Then add the plugin to your tailwind.config.js file:

/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@tailwindcss/typography'),
    // ...
  ],
}

Basic usage

Now you can use the prose classes to add sensible typography styles to any vanilla HTML:

<article class="prose lg:prose-xl">
  <h1>Garlic bread with cheese: What the science tells us</h1>
  <p>
    For years parents have espoused the health benefits of eating garlic bread with cheese to their
    children, with the food earning such an iconic status in our culture that kids will often dress
    up as warm, cheesy loaf for Halloween.
  </p>
  <p>
    But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
    springing up around the country.
  </p>
  <!-- ... -->
</article>

Choosing a gray scale

This plugin includes a modifier class for each of the five gray scales Tailwind includes by default so you can easily style your content to match the grays you're using in your project.

<article class="prose prose-slate">{{ markdown }}</article>

Here are the classes that are generated using a totally default Tailwind CSS v2.0 build:

Class Gray scale
prose-gray (default) Gray
prose-slate Slate
prose-zinc Zinc
prose-neutral Neutral
prose-stone Stone

Modifier classes are designed to be used with the multi-class modifier pattern and must be used in conjunction with the base prose class.

[!NOTE] Always include the prose class when adding a gray scale modifier

<article class="prose prose-stone">{{ markdown }}</article>

To learn about creating your own color themes, read the adding custom color themes documentation.

Applying a type scale

Size modifiers allow you to adjust the overall size of your typography for different contexts.

<article class="prose prose-xl">{{ markdown }}</article>

Five different typography sizes are included out of the box:

Class Body font size
prose-sm 0.875rem (14px)
prose-base (default) 1rem (16px)
prose-lg 1.125rem (18px)
prose-xl 1.25rem (20px)
prose-2xl 1.5rem (24px)

These can be used in combination with Tailwind's breakpoint modifiers to change the overall font size of a piece of content at different viewport sizes:

<article class="prose md:prose-lg lg:prose-xl">{{ markdown }}</article>

Everything about the provided size modifiers has been hand-tuned by professional designers to look as beautiful as possible, including the relationships between font sizes, heading spacing, code block padding, and more.

Size modifiers are designed to be used with the multi-class modifier pattern and must be used in conjunction with the base prose class.

[!NOTE] Always include the prose class when adding a size modifier

<article class="prose prose-lg">{{ markdown }}</article>

To learn about customizing the included type scales, read the documentation on customizing the CSS.

Adapting to dark mode

Each default color theme includes a hand-designed dark mode version that you can trigger by adding the prose-invert class:

<article class="prose dark:prose-invert">{{ markdown }}</article>

To learn about creating your own color themes, read the adding custom color themes documentation.

Element modifiers

Use element modifiers to customize the style of individual elements in your content directly in your HTML:

<article class="prose prose-img:rounded-xl prose-headings:underline prose-a:text-blue-600">
  {{ markdown }}
</article>

This makes it easy to do things like style links to match your brand, add a border radius to images, and tons more.

Here's a complete list of available element modifiers:

Modifier Target
prose-headings:{utility} h1, h2, h3, h4, th
prose-lead:{utility} [class~="lead"]
prose-h1:{utility} h1
prose-h2:{utility} h2
prose-h3:{utility} h3
prose-h4:{utility} h4
prose-p:{utility} p
prose-a:{utility} a
prose-blockquote:{utility} blockquote
prose-figure:{utility} figure
prose-figcaption:{utility} figcaption
prose-strong:{utility} strong
prose-em:{utility} em
prose-kbd:{utility} kbd
prose-code:{utility} code
prose-pre:{utility} pre
prose-ol:{utility} ol
prose-ul:{utility} ul
prose-li:{utility} li
prose-table:{utility} table
prose-thead:{utility} thead
prose-tr:{utility} tr
prose-th:{utility} th
prose-td:{utility} td
prose-img:{utility} img
prose-video:{utility} video
prose-hr:{utility} hr

When stacking these modifiers with other modifiers like hover, you most likely want the other modifier to come first:

<article class="prose prose-a:text-blue-600 hover:prose-a:text-blue-500">{{ markdown }}</article>

Read the Tailwind CSS documentation on ordering stacked modifiers to learn more.

Overriding max-width

Each size modifier comes with a baked in max-width designed to keep the content as readable as possible. This isn't always what you want though, and sometimes you'll want the content to just fill the width of its container.

In those cases, all you need to do is add max-w-none to your content to override the embedded max-width:

<div class="grid grid-cols-4">
  <div class="col-span-1">
    <!-- ... -->
  </div>
  <div class="col-span-3">
    <article class="prose max-w-none">{{ markdown }}</article>
  </div>
</div>

Advanced topics

Undoing typography styles

If you have a block of markup embedded in some content that shouldn't inherit the prose styles, use the not-prose class to sandbox it:

<article class="prose">
  <h1>My Heading</h1>
  <p>...</p>

  <div class="not-prose">
    <!-- Some example or demo that needs to be prose-free -->
  </div>

  <p>...</p>
  <!-- ... -->
</article>

Note that you can't nest new prose instances within a not-prose block at this time.

Adding custom color themes

You can create your own color theme by adding a new key in the typography section of your tailwind.config.js file and providing your colors under the css key:

`js {{ filename: 'tailwind.config.js' }} /** @type {import('tailwindcss').Config} */ module.exports = { theme: { extend: { typography: ({ theme }) => ({ pink: { css: { '--tw-prose-body': theme('colors.pink[800]'), '--tw-prose-headings': theme('colors.pink[900]'), '--tw-prose-lead': theme('colors.pink[700]'), '--tw-prose-links': theme('colors.pink[900]'), '--tw-prose-bold': theme('colors.pink[900]'), '--tw-prose-counters': theme('colors.pink[600]'), '--tw-prose-bullets': theme('colors.pink[400]'), '--tw-prose-hr': theme('colors.pink[300]'), '--tw-prose-quotes': theme('colors.pink[900]'), '--tw-prose-quote-borders': theme('colors.pink[300]'), '--tw-prose-captions': theme('colors.pink[700]'), '--tw-prose-code': theme('colors.pink[900]'), '--tw-prose-pre-code': theme('colors.pink[100]'), '--tw-prose-pre-bg': theme('colors.pink[900]'), '--tw-prose-th-borders': theme('colors.pink[300]'), '--tw-prose-td-borders': theme('colors.pink[200]'), '--tw-prose-invert-body': theme('colors.pink[200]'), '--tw-prose-invert-headings': theme('colors.white'), '--tw-prose-invert-lead': theme('colors.pink[300]'), '--tw-prose-invert-links': theme('colors.white'), '--tw-prose-invert-bold': theme('colors.white'), '--tw-prose-invert-counters': theme('colors.pink[400]'), '--tw-prose-invert-bullets': theme('colors.pink[600]'), '--tw-prose-invert-hr': theme('colors.pink[700]'), '--tw-prose-invert-quotes': theme('colors.pink[100]'), '--tw-prose-invert-quote-borders': theme('colors.pink[700]'), '--tw-prose-invert-captions': theme('colors.pink[400]'), '--tw-prose-invert-code': theme('colors.white'), '--tw-prose-invert-pre-code': theme('colors.pink[300]'), '--tw-prose-invert-pre-bg': 'rgb(0 0 0 / 50%)', '--tw-prose-invert-th-borders': theme('colors.pink[600]'), '--tw-prose-invert-td-borders': theme('colors.pink[700]'), }, }, }), }, }, plugins: [ require('@tailwindcss/typography'), // ... ], }


See our internal [style definitions](https://github.com/tailwindlabs/tailwindcss-typography/blob/main/src/styles.js) for some more examples.

### Changing the default class name

If you need to use a class name other than `prose` for any reason, you can do so using the `className` option when registering the plugin:

```js {{ filename: 'tailwind.config.js' }}
/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@tailwindcss/typography')({
      className: 'wysiwyg',
    }),
  ]
  ...
}

Now every instance of prose in the default class names will be replaced by your custom class name:

<article class="wysiwyg wysiwyg-slate lg:wysiwyg-xl">
  <h1>My Heading</h1>
  <p>...</p>

  <div class="not-wysiwyg">
    <!-- Some example or demo that needs to be prose-free -->
  </div>

  <p>...</p>
  <!-- ... -->
</article>

Customizing the CSS

If you want to customize the raw CSS generated by this plugin, add your overrides under the typography key in the theme section of your tailwind.config.js file:

`js {{ filename: 'tailwind.config.js' }} /** @type {import('tailwindcss').Config} */ module.exports = { theme: { extend: { typography: { DEFAULT: { css: { color: '#333', a: { color: '#3182ce', '&:hover': { color: '#2c5282', }, }, }, }, }, }, }, plugins: [ require('@tailwindcss/typography'), // ... ], }


Like with all theme customizations in Tailwind, you can also define the `typography` key as a function if you need access to the `theme` helper:

```js {{ filename: 'tailwind.config.js' }}
/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    extend: {
      typography: (theme) => ({
        DEFAULT: {
          css: {
            color: theme('colors.gray.800'),

            // ...
          },
        },
      }),
    },
  },
  plugins: [
    require('@tailwindcss/typography'),
    // ...
  ],
}

Customizations should be applied to a specific modifier like DEFAULT or xl, and must be added under the css property. Customizations are authored in the same CSS-in-JS syntax used to write Tailwind plugins.

See the default styles for this plugin for more in-depth examples of configuring each modifier.


Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss the Tailwind CSS Typography plugin on GitHub

For casual chit-chat with others using the framework:

Join the Tailwind CSS Discord Server

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

  • Nothing yet!

0.5.16 - 2025-01-07

Fixed

  • Support installing with beta versions of Tailwind CSS v4 (#365)

0.5.15 - 2024-08-28

Fixed

  • Support installing with alpha versions of Tailwind CSS v4 (#358)

0.5.14 - 2024-08-07

Fixed

  • Fix table text alignment (#346)

0.5.13 - 2024-04-26

Fixed

  • Don't apply margins to <br> elements contained in an <li> in FF (#350)

0.5.12 - 2024-03-27

Added

  • Use logical properties for better RTL support (#323)

0.5.11 - 2024-03-26

Added

  • Add prose-kbd modifier (#340)

Fixed

  • Fix space between <figcaption> and <video> (#339)

0.5.10 - 2023-09-05

Fixed

  • Fix space between <figcaption> and <pre> (#313)
  • Remove typography styles from not-prose elements in addition to their children (#301)
  • Add <picture> styles (#314)
  • Fix prose-invert when used with colors in light mode (#315)
  • Add <kbd> styles (#317)
  • Add description list (<dl>, <dt>, <dd>) styles (#316)

0.5.9 - 2023-01-10

Fixed

  • Ensure p styles are inserted before .lead styles (#294)

0.5.8 - 2022-11-07

Fixed

  • Fix selector when using a non-default class (e.g. prose-sm) (#289)

0.5.7 - 2022-09-02

Fixed

  • Update TypeScript types (#284)

0.5.6 - 2022-09-01

0.5.5 - 2022-09-01

Added

  • Add typescript types (#283)

0.5.4 - 2022-07-12

Fixed

  • Update strong and code color styles to inherit from parent (#276)

0.5.3 - 2022-07-07

Added

  • Add styles for tfoot elements (#243)
  • Add prose-h5 and prose-h6 variants (#273)

Fixed

  • Fix prose elements legacy mode (#259)
  • Allow lead class to override element styles (#260)
  • Fix generation of prose-headings variant (#264)
  • Fix figure spacing (#267)
  • Fix child combinator :where selectors (#268)
  • Fix prose-headings variant to include h5 and h6 elements (#273)

0.5.2 - 2022-02-14

Fixed

  • Ensure nested selectors using &:hover work (#246)

0.5.1 - 2022-01-28

Removed

  • Remove dist folder and related dependencies (#226)

Fixed

  • Don't generate invalid CSS when given an array of property values (#224)

0.5.0 - 2021-12-09

0.5.0-alpha.3 - 2021-11-08

Changes

  • Use :where to reduce specificity, making it possible to override prose children with utilities (#203)
  • Support "undoing" prose styles using the not-prose class on a group of child elements (#205)
  • Update color palette for v3 (#206)
  • Improve customization API, add alternate grays, add dark mode support, use ::marker instead of pseudo-elements, and add child element variants (eg. prose-h1:underline)(#216)

0.5.0-alpha.2 - 2021-11-08

0.5.0-alpha.1 - 2021-11-08

0.4.1 - 2021-05-24

Fixed

  • Fix list-style modifier selectors (#137)

0.4.0 - 2021-01-15

Fixed

  • Colors without 600 variant, breaks everything (#107)
  • Fix empty line in firefox for pre code tags (#125)

Added

  • Add support for the start and reversed attribute on ol elements (#110)
  • Add support for the type on ul and ol elements (#126)

Changed (internal)

  • Bumped dependencies (#103, #115)
  • Cleanup/improve readme (#95)
  • Reduce package size (#112)

0.3.0 - 2020-11-20

Changed

  • Add support for Tailwind CSS v2.0 and drops support for v1.0 (#79, #82, #87)
  • Use extend for any overrides, assigning directly to theme.typography now completely overrides default configuration
  • Consistently use ::before instead of :before (ba33d77)
  • Read color values from the user's theme instead of only the default theme

Added

  • Add new className option for overriding prose class (#28)
  • Add color modifiers by default like prose-blue for setting link styles (#92)

0.2.0 - 2020-07-15

Changes

  • Switches how variants are generated to use the new component variants API in Tailwind 1.5, dropping support for Tailwind < 1.5

0.1.4 - 2020-07-15

Fixes

  • Fixes an issue where the lead class was not being applied correctly when used in conjunction with responsive variants

0.1.3 - 2020-07-14

Fixes

  • Fixes an issue where the configured monospace font family was not used by default for pre and code blocks

0.1.2 - 2020-07-14

Fixes

  • Fixes an issue in our internal rounding logic that would round values like 20 to 2 👀

0.1.1 - 2020-07-14

Fixes

  • Fixes an issue where the plugin was totally broken and didn't work at all because I deleted some code without even testing my changes 🧠

0.1.0 - 2020-07-14

Added

  • Everything!