{"id":13417803,"url":"https://github.com/tailwindlabs/tailwindcss-typography","last_synced_at":"2025-05-12T05:18:32.722Z","repository":{"id":37802864,"uuid":"219020626","full_name":"tailwindlabs/tailwindcss-typography","owner":"tailwindlabs","description":"Beautiful typographic defaults for HTML you don't control.","archived":false,"fork":false,"pushed_at":"2025-03-27T13:01:10.000Z","size":4609,"stargazers_count":5427,"open_issues_count":19,"forks_count":290,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-05-12T02:43:20.381Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://tailwindcss-typography.vercel.app/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tailwindlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-01T16:16:59.000Z","updated_at":"2025-05-11T16:08:56.000Z","dependencies_parsed_at":"2024-03-22T18:43:56.822Z","dependency_job_id":"0a85588e-7072-49a6-b377-6fdc66af5354","html_url":"https://github.com/tailwindlabs/tailwindcss-typography","commit_stats":{"total_commits":238,"total_committers":30,"mean_commits":7.933333333333334,"dds":0.7226890756302521,"last_synced_commit":"383bee7004349a4877c619dafa9aff1854dac601"},"previous_names":["tailwindcss/typography"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailwindlabs%2Ftailwindcss-typography","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailwindlabs%2Ftailwindcss-typography/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailwindlabs%2Ftailwindcss-typography/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailwindlabs%2Ftailwindcss-typography/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tailwindlabs","download_url":"https://codeload.github.com/tailwindlabs/tailwindcss-typography/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253672696,"owners_count":21945480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:00:52.955Z","updated_at":"2025-05-12T05:18:32.684Z","avatar_url":"https://github.com/tailwindlabs.png","language":"JavaScript","readme":"\u003cp\u003e\n  \u003ca href=\"https://tailwindcss.com/docs/typography-plugin\" target=\"_blank\"\u003e\n    \u003cpicture\u003e\n      \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-dark.svg\"\u003e\n      \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-light.svg\"\u003e\n      \u003cimg alt=\"Tailwind CSS Typography\" src=\"https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-light.svg\" width=\"450\" height=\"70\" style=\"max-width: 100%;\"\u003e\n    \u003c/picture\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nThe 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.\n\n```html\n\u003carticle class=\"prose lg:prose-xl\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nTo see what it looks like in action, check out our [live demo](https://play.tailwindcss.com/uj1vGACRJA?layout=preview) on Tailwind Play.\n\n---\n\n## Installation\n\nInstall the plugin from npm:\n\n```shell\nnpm install -D @tailwindcss/typography\n```\n\nThen add the plugin to your main `style.css` file:\n\n```diff\n  @import \"tailwindcss\";\n+ @plugin \"@tailwindcss/typography\";\n```\n\n---\n\n## Basic usage\n\nNow you can use the `prose` classes to add sensible typography styles to any vanilla HTML:\n\n```html\n\u003carticle class=\"prose lg:prose-xl\"\u003e\n  \u003ch1\u003eGarlic bread with cheese: What the science tells us\u003c/h1\u003e\n  \u003cp\u003e\n    For years parents have espoused the health benefits of eating garlic bread with cheese to their\n    children, with the food earning such an iconic status in our culture that kids will often dress\n    up as warm, cheesy loaf for Halloween.\n  \u003c/p\u003e\n  \u003cp\u003e\n    But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases\n    springing up around the country.\n  \u003c/p\u003e\n  \u003c!-- ... --\u003e\n\u003c/article\u003e\n```\n\n### Choosing a gray scale\n\nThis 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.\n\n```html\n\u003carticle class=\"prose prose-slate\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nHere are the classes that are generated using a totally default Tailwind CSS v2.0 build:\n\n| Class                    | Gray scale |\n| ------------------------ | ---------- |\n| `prose-gray` _(default)_ | Gray       |\n| `prose-slate`            | Slate      |\n| `prose-zinc`             | Zinc       |\n| `prose-neutral`          | Neutral    |\n| `prose-stone`            | Stone      |\n\nModifier classes are designed to be used with the [multi-class modifier pattern](http://nicolasgallagher.com/about-html-semantics-front-end-architecture/#component-modifiers) and must be used in conjunction with the base `prose` class.\n\n\u003e [!NOTE]\n\u003e Always include the `prose` class when adding a gray scale modifier\n\n```html\n\u003carticle class=\"prose prose-stone\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nTo learn about creating your own color themes, read the [adding custom color themes](#adding-custom-color-themes) documentation.\n\n### Applying a type scale\n\nSize modifiers allow you to adjust the overall size of your typography for different contexts.\n\n```html\n\u003carticle class=\"prose prose-xl\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nFive different typography sizes are included out of the box:\n\n| Class                    | Body font size    |\n| ------------------------ | ----------------- |\n| `prose-sm`               | 0.875rem _(14px)_ |\n| `prose-base` _(default)_ | 1rem _(16px)_     |\n| `prose-lg`               | 1.125rem _(18px)_ |\n| `prose-xl`               | 1.25rem _(20px)_  |\n| `prose-2xl`              | 1.5rem _(24px)_   |\n\nThese can be used in combination with Tailwind's [breakpoint modifiers](https://tailwindcss.com/docs/responsive-design) to change the overall font size of a piece of content at different viewport sizes:\n\n```html\n\u003carticle class=\"prose md:prose-lg lg:prose-xl\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nEverything 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.\n\nSize modifiers are designed to be used with the [multi-class modifier pattern](http://nicolasgallagher.com/about-html-semantics-front-end-architecture/#component-modifiers) and must be used in conjunction with the base `prose` class.\n\n\u003e [!NOTE]\n\u003e Always include the `prose` class when adding a size modifier\n\n```html\n\u003carticle class=\"prose prose-lg\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nTo learn about customizing the included type scales, read the documentation on [customizing the CSS](#customizing-the-css).\n\n### Adapting to dark mode\n\nEach default color theme includes a hand-designed dark mode version that you can trigger by adding the `prose-invert` class:\n\n```html\n\u003carticle class=\"prose dark:prose-invert\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nTo learn about creating your own color themes, read the [adding custom color themes](#adding-custom-color-themes) documentation.\n\n### Element modifiers\n\nUse element modifiers to customize the style of individual elements in your content directly in your HTML:\n\n```html\n\u003carticle class=\"prose prose-img:rounded-xl prose-headings:underline prose-a:text-blue-600\"\u003e\n  {{ markdown }}\n\u003c/article\u003e\n```\n\nThis makes it easy to do things like style links to match your brand, add a border radius to images, and tons more.\n\nHere's a complete list of available element modifiers:\n\n| Modifier                     | Target                       |\n| ---------------------------- | ---------------------------- |\n| `prose-headings:{utility}`   | `h1`, `h2`, `h3`, `h4`, `th` |\n| `prose-lead:{utility}`       | `[class~=\"lead\"]`            |\n| `prose-h1:{utility}`         | `h1`                         |\n| `prose-h2:{utility}`         | `h2`                         |\n| `prose-h3:{utility}`         | `h3`                         |\n| `prose-h4:{utility}`         | `h4`                         |\n| `prose-p:{utility}`          | `p`                          |\n| `prose-a:{utility}`          | `a`                          |\n| `prose-blockquote:{utility}` | `blockquote`                 |\n| `prose-figure:{utility}`     | `figure`                     |\n| `prose-figcaption:{utility}` | `figcaption`                 |\n| `prose-strong:{utility}`     | `strong`                     |\n| `prose-em:{utility}`         | `em`                         |\n| `prose-kbd:{utility}`        | `kbd`                        |\n| `prose-code:{utility}`       | `code`                       |\n| `prose-pre:{utility}`        | `pre`                        |\n| `prose-ol:{utility}`         | `ol`                         |\n| `prose-ul:{utility}`         | `ul`                         |\n| `prose-li:{utility}`         | `li`                         |\n| `prose-table:{utility}`      | `table`                      |\n| `prose-thead:{utility}`      | `thead`                      |\n| `prose-tr:{utility}`         | `tr`                         |\n| `prose-th:{utility}`         | `th`                         |\n| `prose-td:{utility}`         | `td`                         |\n| `prose-img:{utility}`        | `img`                        |\n| `prose-video:{utility}`      | `video`                      |\n| `prose-hr:{utility}`         | `hr`                         |\n\nWhen stacking these modifiers with other modifiers like `hover`, you most likely want the other modifier to come last:\n\n```html\n\u003carticle class=\"prose prose-a:text-blue-600 prose-a:hover:text-blue-500\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nIf you are still using in Tailwind CSS v3, the modifier order is the opposite:\n\n```html\n\u003carticle class=\"prose prose-a:text-blue-600 hover:prose-a:text-blue-500\"\u003e{{ markdown }}\u003c/article\u003e\n```\n\nRead the Tailwind CSS documentation on [stacked modifiers](https://tailwindcss.com/docs/hover-focus-and-other-states) to learn more.\n\n### Overriding max-width\n\nEach 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.\n\nIn those cases, all you need to do is add `max-w-none` to your content to override the embedded max-width:\n\n```html\n\u003cdiv class=\"grid grid-cols-4\"\u003e\n  \u003cdiv class=\"col-span-1\"\u003e\n    \u003c!-- ... --\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"col-span-3\"\u003e\n    \u003carticle class=\"prose max-w-none\"\u003e{{ markdown }}\u003c/article\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n---\n\n## Advanced topics\n\n### Undoing typography styles\n\nIf 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:\n\n```html\n\u003carticle class=\"prose\"\u003e\n  \u003ch1\u003eMy Heading\u003c/h1\u003e\n  \u003cp\u003e...\u003c/p\u003e\n\n  \u003cdiv class=\"not-prose\"\u003e\n    \u003c!-- Some example or demo that needs to be prose-free --\u003e\n  \u003c/div\u003e\n\n  \u003cp\u003e...\u003c/p\u003e\n  \u003c!-- ... --\u003e\n\u003c/article\u003e\n```\n\nNote that you can't nest new `prose` instances within a `not-prose` block at this time.\n\n### Adding custom color themes\n\nTo customize the color theme beyond simple CSS overrides, you can use the JavaScript based theme API. To do that, use the `@config` directive:\n\n```diff\n  @import \"tailwindcss\";\n  @plugin \"@tailwindcss/typography\";\n+ @config \"./tailwind.config.js\";\n```\n\nYou can then create your own color theme by adding a new `tailwind.config.js` file with the `typography` section and providing your colors under the `css` key:\n\n```js {{ filename: 'tailwind.config.js' }}\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  theme: {\n    extend: {\n      typography: () =\u003e ({\n        pink: {\n          css: {\n            '--tw-prose-body': 'var(--color-pink-800)',\n            '--tw-prose-headings': 'var(--color-pink-900)',\n            '--tw-prose-lead': 'var(--color-pink-700)',\n            '--tw-prose-links': 'var(--color-pink-900)',\n            '--tw-prose-bold': 'var(--color-pink-900)',\n            '--tw-prose-counters': 'var(--color-pink-600)',\n            '--tw-prose-bullets': 'var(--color-pink-400)',\n            '--tw-prose-hr': 'var(--color-pink-300)',\n            '--tw-prose-quotes': 'var(--color-pink-900)',\n            '--tw-prose-quote-borders': 'var(--color-pink-300)',\n            '--tw-prose-captions': 'var(--color-pink-700)',\n            '--tw-prose-code': 'var(--color-pink-900)',\n            '--tw-prose-pre-code': 'var(--color-pink-100)',\n            '--tw-prose-pre-bg': 'var(--color-pink-900)',\n            '--tw-prose-th-borders': 'var(--color-pink-300)',\n            '--tw-prose-td-borders': 'var(--color-pink-200)',\n            '--tw-prose-invert-body': 'var(--color-pink-200)',\n            '--tw-prose-invert-headings': 'var(--color-white)',\n            '--tw-prose-invert-lead': 'var(--color-pink-300)',\n            '--tw-prose-invert-links': 'var(--color-white)',\n            '--tw-prose-invert-bold': 'var(--color-white)',\n            '--tw-prose-invert-counters': 'var(--color-pink-400)',\n            '--tw-prose-invert-bullets': 'var(--color-pink-600)',\n            '--tw-prose-invert-hr': 'var(--color-pink-700)',\n            '--tw-prose-invert-quotes': 'var(--color-pink-100)',\n            '--tw-prose-invert-quote-borders': 'var(--color-pink-700)',\n            '--tw-prose-invert-captions': 'var(--color-pink-400)',\n            '--tw-prose-invert-code': 'var(--color-white)',\n            '--tw-prose-invert-pre-code': 'var(--color-pink-300)',\n            '--tw-prose-invert-pre-bg': 'rgb(0 0 0 / 50%)',\n            '--tw-prose-invert-th-borders': 'var(--color-pink-600)',\n            '--tw-prose-invert-td-borders': 'var(--color-pink-700)',\n          },\n        },\n      }),\n    },\n  },\n}\n```\n\nSee our internal [style definitions](https://github.com/tailwindlabs/tailwindcss-typography/blob/main/src/styles.js) for some more examples.\n\n### Changing the default class name\n\nIf 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:\n\n```css\n@import \"tailwindcss\";\n@plugin \"@tailwindcss/typography\" {\n  className: wysiwyg;\n}\n```\n\nNow every instance of `prose` in the default class names will be replaced by your custom class name:\n\n```html\n\u003carticle class=\"wysiwyg wysiwyg-slate lg:wysiwyg-xl\"\u003e\n  \u003ch1\u003eMy Heading\u003c/h1\u003e\n  \u003cp\u003e...\u003c/p\u003e\n\n  \u003cdiv class=\"not-wysiwyg\"\u003e\n    \u003c!-- Some example or demo that needs to be prose-free --\u003e\n  \u003c/div\u003e\n\n  \u003cp\u003e...\u003c/p\u003e\n  \u003c!-- ... --\u003e\n\u003c/article\u003e\n```\n\n### Customizing the CSS\n\nIf you want to customize the raw CSS generated by this plugin, first follow the steps from [adding custom color themes](#adding-custom-color-themes) to set up a JavaScript based configuration API and then add your overrides under the `typography` key in the `theme` section of your `tailwind.config.js` file:\n\n```js {{ filename: 'tailwind.config.js' }}\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  theme: {\n    extend: {\n      typography: {\n        DEFAULT: {\n          css: {\n            color: '#333',\n            a: {\n              color: '#3182ce',\n              '\u0026:hover': {\n                color: '#2c5282',\n              },\n            },\n          },\n        },\n      },\n    },\n  },\n}\n```\n\nLike with all theme customizations in Tailwind, you can use CSS variables if you need access to access your theme configuration:\n\n```js {{ filename: 'tailwind.config.js' }}\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  theme: {\n    extend: {\n      typography: {\n        DEFAULT: {\n          css: {\n            color: 'var(--color-gray-800)',\n            // ...\n          },\n        },\n      },\n    },\n  },\n}\n```\n\nCustomizations 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](https://v3.tailwindcss.com/docs/plugins#css-in-js-syntax) used to write Tailwind v3 plugins.\n\nSee [the default styles](https://github.com/tailwindlabs/tailwindcss-typography/blob/main/src/styles.js) for this plugin for more in-depth examples of configuring each modifier.\n\n---\n\n## Community\n\nFor help, discussion about best practices, or any other conversation that would benefit from being searchable:\n\n[Discuss the Tailwind CSS Typography plugin on GitHub](https://github.com/tailwindlabs/tailwindcss/discussions)\n\nFor casual chit-chat with others using the framework:\n\n[Join the Tailwind CSS Discord Server](https://tailwindcss.com/discord)\n","funding_links":[],"categories":["What Do I Use...","JavaScript","Plugins","🔧 Utilities \u0026 Miscellaneous","CSS 相关","others","Uncategorized","Plugins \u0026 Extensions"],"sub_categories":["If I want to style my markdown?","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftailwindlabs%2Ftailwindcss-typography","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftailwindlabs%2Ftailwindcss-typography","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftailwindlabs%2Ftailwindcss-typography/lists"}