Skip to content

Commit 007d109

Browse files
committed
Update README
1 parent 5482ee9 commit 007d109

File tree

1 file changed

+63
-71
lines changed

1 file changed

+63
-71
lines changed

README.md

Lines changed: 63 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<img alt="Tailwind CSS Typography" width="350" src="./.github/logo.svg">
33
</p>
44

5+
**As of v0.3.0, @tailwindcss/typography is designed for Tailwind CSS v2.0+.**
6+
57
A plugin that 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).
68

79
[View live demo](https://tailwindcss-typography.netlify.app/)
@@ -125,58 +127,40 @@ Size modifiers are designed to be used with the [multi-class modifier pattern](h
125127
</article>
126128
```
127129

128-
### Responsive variants
130+
### Color modifiers
129131

130-
None of the sizes are automatically responsive, but responsive variants are provided for each size modifier so you can easily change the typography size at different breakpoints:
132+
Color modifiers allow you to "brand" your typography sections by changing the link color. By default, modifiers are generated for every color in your color palette that include a `600` shade except for `gray` since it's the default.
131133

132134
```html
133-
<article class="prose prose-sm sm:prose lg:prose-lg xl:prose-xl">
135+
<article class="prose prose-indigo">
134136
{{ markdown }}
135137
</article>
136138
```
137139

138-
## Purging unused styles
139-
140-
Since the typography styles are added to the `components` layer and Tailwind only purges `utilities` by default, you will notice that even with the `purge` option configured in your `tailwind.config.js` file, all of the typography styles still remain in your final CSS.
141-
142-
If you'd like to purge unused typography styles, you'll need to use the `mode: 'all'` option in your `purge` configuration:
143-
144-
```js
145-
// tailwind.config.js
146-
module.exports = {
147-
purge: {
148-
mode: 'all',
149-
content: [
150-
// Paths to your templates here...
151-
],
152-
},
153-
}
154-
```
140+
Here are the classes that are generated using a totally default Tailwind CSS v2.0 build:
155141

156-
It's important to note that if you are using markdown for any of your source files (perhaps you're working on a blog or similar), that you need to be careful not to accidentally purge styles you actually need.
142+
| Class | Link color |
143+
| -------------- | ------------ |
144+
| `prose-red` | `red.600` |
145+
| `prose-yellow` | `yellow.600` |
146+
| `prose-green` | `green.600` |
147+
| `prose-blue` | `blue.600` |
148+
| `prose-indigo` | `indigo.600` |
149+
| `prose-purple` | `purple.600` |
150+
| `prose-pink` | `pink.600` |
157151

158-
Markdown files for example contain no actual `h2`, `blockquote`, `strong`, etc. elements, so PurgeCSS will remove those styles because it doesn't think you need them.
152+
For more control, use the [low-level customization API](#customization).
159153

160-
You have two options for solving this:
154+
### Responsive variants
161155

162-
1. Safelist all of the plain HTML elements you need in your config file:
156+
None of the sizes are automatically responsive, but responsive variants are provided for each size modifier so you can easily change the typography size at different breakpoints:
163157

164-
```js
165-
// tailwind.config.js
166-
module.exports = {
167-
purge: {
168-
mode: 'all',
169-
content: [
170-
// Paths to your templates here...
171-
],
172-
options: {
173-
whitelist: ['h1', 'h2', 'h3', 'p', 'blockquote', 'strong' /* etc. */],
174-
},
175-
},
176-
}
177-
```
158+
```html
159+
<article class="prose prose-sm sm:prose lg:prose-lg xl:prose-xl">
160+
{{ markdown }}
161+
</article>
162+
```
178163

179-
2. Use a custom extractor to compile your markdown files _before_ scanning them for tokens. This is more complicated but it is [what we do for the Tailwind blog](https://github.com/tailwindlabs/blog.tailwindcss.com/blob/eb2a0ff80c8e56a79f6514c8dc4253ef84ac5548/tailwind.config.js#L13) for example.
180164

181165
## Customization
182166

@@ -188,18 +172,20 @@ To customize the styles provided by this plugin, add your overrides under the `t
188172
// tailwind.config.js
189173
module.exports = {
190174
theme: {
191-
typography: {
192-
default: {
193-
css: {
194-
color: '#333',
195-
a: {
196-
color: '#3182ce',
197-
'&:hover': {
198-
color: '#2c5282',
175+
extend: {
176+
typography: {
177+
default: {
178+
css: {
179+
color: '#333',
180+
a: {
181+
color: '#3182ce',
182+
'&:hover': {
183+
color: '#2c5282',
184+
},
199185
},
200186
},
201187
},
202-
},
188+
}
203189
},
204190
},
205191
plugins: [
@@ -215,15 +201,17 @@ Like with all theme customizations in Tailwind, you can also define the `typogra
215201
// tailwind.config.js
216202
module.exports = {
217203
theme: {
218-
typography: (theme) => ({
219-
default: {
220-
css: {
221-
color: theme('colors.gray.800'),
204+
extend: {
205+
typography: (theme) => ({
206+
default: {
207+
css: {
208+
color: theme('colors.gray.800'),
222209

223-
// ...
210+
// ...
211+
},
224212
},
225-
},
226-
}),
213+
}),
214+
}
227215
},
228216
plugins: [
229217
require('@tailwindcss/typography'),
@@ -248,17 +236,19 @@ If you'd like to customize these sorts of styles, do so using the `default` modi
248236
// tailwind.config.js
249237
module.exports = {
250238
theme: {
251-
typography: {
252-
default: {
253-
css: {
254-
color: '#333',
255-
strong: {
256-
fontWeight: '800',
239+
extend: {
240+
typography: {
241+
default: {
242+
css: {
243+
color: '#333',
244+
strong: {
245+
fontWeight: '800',
246+
},
247+
// ...
257248
},
258-
// ...
259249
},
260250
},
261-
},
251+
}
262252
},
263253
plugins: [
264254
require('@tailwindcss/typography'),
@@ -275,17 +265,19 @@ You can add a new modifier by creating a new key in the `typography` section of
275265
// tailwind.config.js
276266
module.exports = {
277267
theme: {
278-
typography: {
279-
'3xl': {
280-
css: {
281-
fontSize: '1.875rem',
282-
h1: {
283-
fontSize: '4rem',
268+
extend: {
269+
typography: {
270+
'3xl': {
271+
css: {
272+
fontSize: '1.875rem',
273+
h1: {
274+
fontSize: '4rem',
275+
},
276+
// ...
284277
},
285-
// ...
286278
},
287279
},
288-
},
280+
}
289281
},
290282
plugins: [
291283
require('@tailwindcss/typography'),

0 commit comments

Comments
 (0)