You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**As of v0.3.0, @tailwindcss/typography is designed for Tailwind CSS v2.0+.**
6
+
5
7
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).
6
8
7
9
[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
125
127
</article>
126
128
```
127
129
128
-
### Responsive variants
130
+
### Color modifiers
129
131
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.
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:
155
141
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`|
157
151
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).
159
153
160
-
You have two options for solving this:
154
+
### Responsive variants
161
155
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:
163
157
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. */],
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.
180
164
181
165
## Customization
182
166
@@ -188,18 +172,20 @@ To customize the styles provided by this plugin, add your overrides under the `t
188
172
// tailwind.config.js
189
173
module.exports= {
190
174
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
+
},
199
185
},
200
186
},
201
187
},
202
-
},
188
+
}
203
189
},
204
190
},
205
191
plugins: [
@@ -215,15 +201,17 @@ Like with all theme customizations in Tailwind, you can also define the `typogra
215
201
// tailwind.config.js
216
202
module.exports= {
217
203
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'),
222
209
223
-
// ...
210
+
// ...
211
+
},
224
212
},
225
-
},
226
-
}),
213
+
}),
214
+
}
227
215
},
228
216
plugins: [
229
217
require('@tailwindcss/typography'),
@@ -248,17 +236,19 @@ If you'd like to customize these sorts of styles, do so using the `default` modi
248
236
// tailwind.config.js
249
237
module.exports= {
250
238
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
+
// ...
257
248
},
258
-
// ...
259
249
},
260
250
},
261
-
},
251
+
}
262
252
},
263
253
plugins: [
264
254
require('@tailwindcss/typography'),
@@ -275,17 +265,19 @@ You can add a new modifier by creating a new key in the `typography` section of
0 commit comments