Tailwind Plugins & Ecosystem — Tailwind CSS

A plugin is an extra package that gives Tailwind new classes. Install it in two steps: npm install -D @tailwindcss/typography in the terminal, then @plugin…

You put a blog article written in Markdown (a way to write text with simple marks, such as a hash sign for a heading) into a Tailwind page. All of it looks bare: headings as small as plain text, lists with no bullets, and links that don't look like links. Tailwind on its own has no class for tidying up an article like this.

Classes for articles come from a plugin: an extra package that gives Tailwind new classes, such as prose for tidying up an article. Think of a power drill. Tailwind is the drill, with its standard bits: the built-in classes such as p-4, flex and text-blue-600. A plugin is an extra bit: you buy it first (npm install), then fit it to the drill (@plugin). A bit lying in the box doesn't let the drill do anything new. In the same way, a plugin that is installed but not added with @plugin gives you no new classes.

Why an article looks bare

Tailwind always includes Preflight, its base CSS that removes the browser's default styles. So an h2 is as big as normal text, a ul has no bullets, and links are the same colour as the text. For components that's good, because you set all their styles with classes. But an article from Markdown or from a CMS (an app for writing a website's content, such as WordPress) is written by someone else, and a program makes its HTML. So you can't put a class on each of its h2 and p tags. For example, this article has no classes at all:

<article>
  <h2>Getting started with Tailwind</h2>
  <p>Tailwind gives you <strong>small classes</strong> for each style. The guide is in the <a href="#">official docs</a>.</p>
  <ul>
    <li>Install it with npm</li>
    <li>Write classes in your HTML</li>
    <li>Run the build</li>
  </ul>
  <blockquote><p>Start small, tidy up later.</p></blockquote>
</article>

The @tailwindcss/typography plugin is an official plugin (made by the Tailwind team) for HTML or Markdown content. One class on the <article>, the parent of all the article's elements, is enough: <article class="prose">. Every element inside it gets tidied up.

Element Without prose (Preflight) With prose
h2 16px, normal weight 24px, bold 700, 24px of space below it
p stuck to each other 20px between blocks
ul no bullets round bullets, indented 26px
a same as normal text underlined, weight 500
blockquote normal text italic, a 4px left line, quote marks

With prose, the article's text is 16px with a 28px line-height, in dark grey. Its width is capped at 65ch (about 65 letters per line) so it's comfortable to read.

Installing a plugin: two steps

First, install the plugin in the terminal:

npm install -D @tailwindcss/typography

Second, write the @plugin line in your main CSS file, below @import:

/* app.css */
@import "tailwindcss";
@plugin "@tailwindcss/typography";

If the @plugin line is missing, nothing happens. There's no error, and the article stays bare. Without @plugin, Tailwind doesn't know the name prose, so its CSS is never made. A class Tailwind doesn't know is only a name with no style.

Tuning prose

Another official plugin: forms

@tailwindcss/forms resets input, select, textarea and checkboxes so they look plain and the same in every browser. That makes form elements easy to style with classes, such as rounded-md border-gray-300 focus:border-blue-500. Installing it works the same way: npm install -D @tailwindcss/forms, then @plugin "@tailwindcss/forms";.

Some old official plugins are part of Tailwind now, so don't install them again: aspect-ratio (aspect-video), line-clamp (line-clamp-3), and container-queries (@container, @md:, built in since v4).

Not everything needs a plugin: @utility

Need one small class that Tailwind doesn't have yet? In v4, you can write it yourself with @utility in your CSS file, with no plugin. For example, a class that hides the scrollbar:

@utility scrollbar-hidden {
  scrollbar-width: none;
  &::-webkit-scrollbar { display: none; }
}

Now class="scrollbar-hidden" hides the scrollbar, and the class can take a prefix: md:scrollbar-hidden only applies from 768px. Text shadows (text-shadow-lg) used to be a favourite home-made plugin. Since v4.1, they are built into Tailwind.

Tailwind v3: plugins in tailwind.config.js

In a Tailwind v3 project, plugins go in the plugins array (a list) of the config file:

// tailwind.config.js (Tailwind v3)
module.exports = {
  plugins: [require("@tailwindcss/forms"), require("@tailwindcss/typography")],
}

Tailwind v4 doesn't read this file on its own. In v4, use @plugin in your CSS. An old project that still has a config file can load it with @config "./tailwind.config.js"; in the CSS.

The ecosystem: ready-made components

Tailwind's ecosystem is the tools and libraries used with Tailwind, made by the Tailwind team and by others. Before you choose a component library, install these two official tools in your code editor:

A component library holds ready-made UI components. Three well-known ones:

⚠️ A prose that does nothing, or an article that suddenly goes narrow

TL;DR: A plugin is an extra package that gives Tailwind new classes. Install it in two steps: npm install -D @tailwindcss/typography in the terminal, then @plugin "@tailwindcss/typography"; in the main CSS file (v4). @tailwindcss/typography is the official plugin for HTML or Markdown content: one prose class on the <article> tidies the headings, paragraphs, lists, links and quotes inside it. Without @plugin, prose does nothing, with no error. Tune it with prose-lg (bigger), max-w-none (no width cap), dark:prose-invert (dark mode), and prose-a:... (links only). @tailwindcss/forms makes form elements plain and the same everywhere. A small class of your own only needs @utility. In v3, plugins go in tailwind.config.js: plugins: [require("@tailwindcss/forms")]. The ecosystem (tools and libraries used with Tailwind): daisyUI (ready-made component classes), Headless UI (components with no styles that already work with the keyboard), shadcn/ui (component code you copy into your project).

⚡ One class for the whole article

Write:

<article class="prose">
  <h2>Getting started with Tailwind</h2>
  <p>Tailwind gives you <strong>small classes</strong> for each style. The guide is in the <a href="#">official docs</a>.</p>
</article>

Meaning: prose is a class from @tailwindcss/typography, an official Tailwind plugin (an extra package). One prose on the <article> tidies the headings, paragraphs, lists, links and quotes inside it, with no class on each element. Its width is capped at 65ch (about 65 letters per line) so it's comfortable to read. Want it as wide as its parent? Add max-w-none.

⚡ Install, then add it

Write:

@import "tailwindcss";
@plugin "@tailwindcss/typography";

Meaning: First, npm install -D @tailwindcss/typography in the terminal downloads the plugin. Second, the @plugin line in the main CSS file adds it. Only then does Tailwind make the prose class.

⚡ Forgetting @plugin

Guess first: the plugin is installed, but the @plugin line isn't written. What happens?

Nothing, and there's no error. Tailwind doesn't know the name prose, so its CSS isn't made and the article stays plain.

Meaning: A class Tailwind doesn't know is only a name with no styles. If prose does nothing, first check the @plugin line in the main CSS file.

What you will learn