Skip to content

Commit 684cfc6

Browse files
committed
Simplify readme
1 parent 24f3595 commit 684cfc6

File tree

1 file changed

+11
-365
lines changed

1 file changed

+11
-365
lines changed

README.md

Lines changed: 11 additions & 365 deletions
Original file line numberDiff line numberDiff line change
@@ -1,375 +1,21 @@
1-
<p>
1+
<a href="https://tailwindcss.com/" target="_blank">
22
<img alt="Tailwind CSS Typography" width="350" src="./.github/logo.svg">
3-
</p>
3+
</a>
44

5-
**As of v0.3.0, @tailwindcss/typography is designed for Tailwind CSS v2.0+.**
5+
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.
66

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).
7+
---
88

9-
[View live demo](https://tailwindcss-typography.vercel.app/)
9+
## Documentation
1010

11-
```html
12-
<article class="prose lg:prose-xl">
13-
{{ markdown }}
14-
</article>
15-
```
11+
For full documentation, visit [tailwindcss.com/docs/typography-plugin](https://tailwindcss.com/docs/typography-plugin).
1612

17-
## Installation
13+
## Community
1814

19-
Install the plugin from npm:
15+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
2016

21-
```sh
22-
# Using npm
23-
npm install @tailwindcss/typography
17+
[Discuss the Tailwind CSS Typography plugin on GitHub](https://github.com/tailwindlabs/tailwindcss/discussions)
2418

25-
# Using Yarn
26-
yarn add @tailwindcss/typography
27-
```
19+
For casual chit-chat with others using the framework:
2820

29-
Then add the plugin to your `tailwind.config.js` file:
30-
31-
```js
32-
// tailwind.config.js
33-
module.exports = {
34-
theme: {
35-
// ...
36-
},
37-
plugins: [
38-
require('@tailwindcss/typography'),
39-
// ...
40-
],
41-
}
42-
```
43-
44-
### Using a CDN
45-
46-
If you need to pull in these styles via CDN, you can do so using services like UNPKG or jsDeliver:
47-
48-
```html
49-
<!-- From UNPKG -->
50-
<link
51-
rel="stylesheet"
52-
href="https://unpkg.com/@tailwindcss/typography@0.4.x/dist/typography.min.css"
53-
/>
54-
55-
<!-- From jsDelivr -->
56-
<link
57-
rel="stylesheet"
58-
href="https://cdn.jsdelivr.net/npm/@tailwindcss/typography@0.4.x/dist/typography.min.css"
59-
/>
60-
```
61-
62-
To use these styles alongside the rest of Tailwind via CDN, we recommend pulling in each layer separately so you can put the styles in the correct order:
63-
64-
```html
65-
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^1.5/dist/base.min.css" />
66-
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^1.5/dist/components.min.css" />
67-
<link
68-
rel="stylesheet"
69-
href="https://unpkg.com/@tailwindcss/typography@0.2.x/dist/typography.min.css"
70-
/>
71-
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^1.5/dist/utilities.min.css" />
72-
```
73-
74-
## Usage
75-
76-
Now you can use the `prose` classes to add sensible typography styles to any vanilla HTML:
77-
78-
```html
79-
<article class="prose lg:prose-xl">
80-
<h1>Garlic bread with cheese: What the science tells us</h1>
81-
<p>
82-
For years parents have espoused the health benefits of eating garlic bread with cheese to their
83-
children, with the food earning such an iconic status in our culture that kids will often dress
84-
up as warm, cheesy loaf for Halloween.
85-
</p>
86-
<p>
87-
But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
88-
springing up around the country.
89-
</p>
90-
<!-- ... -->
91-
</article>
92-
```
93-
94-
### Size modifiers
95-
96-
Size modifiers allow you to adjust the overall size of your typography for different contexts.
97-
98-
```html
99-
<article class="prose prose-xl">
100-
{{ markdown }}
101-
</article>
102-
```
103-
104-
Five different typography sizes are included out of the box:
105-
106-
| Class | Body font size |
107-
| ----------- | --------------: |
108-
| `prose-sm` | 0.875rem (14px) |
109-
| `prose` | 1rem (16px) |
110-
| `prose-lg` | 1.125rem (18px) |
111-
| `prose-xl` | 1.25rem (20px) |
112-
| `prose-2xl` | 1.5rem (24px) |
113-
114-
Everything about the provided size modifiers has been hand-tuned to look as beautiful as possible, including the relationships between font sizes, heading spacing, code block padding, etc. Just like the Tailwind color palettes, none of these styles are based on naive mathematical formulas, and have been hand-crafted by professional designers.
115-
116-
Size 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**:
117-
118-
```html
119-
<!-- Will not work -->
120-
<article class="prose-lg">
121-
{{ markdown }}
122-
</article>
123-
124-
<!-- Always add the `prose` class -->
125-
<article class="prose prose-lg">
126-
{{ markdown }}
127-
</article>
128-
```
129-
130-
### Color modifiers
131-
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.
133-
134-
```html
135-
<article class="prose prose-indigo">
136-
{{ markdown }}
137-
</article>
138-
```
139-
140-
Here are the classes that are generated using a totally default Tailwind CSS v2.0 build:
141-
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` |
151-
152-
For more control, use the [low-level customization API](#customization).
153-
154-
### Responsive variants
155-
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:
157-
158-
```html
159-
<article class="prose prose-sm sm:prose lg:prose-lg xl:prose-xl">
160-
{{ markdown }}
161-
</article>
162-
```
163-
164-
165-
## Customization
166-
167-
> The customization API is currently extremely low-level in order to be as flexible as possible. We will be introducing higher-level configuration options over time as we learn what types of customizations are most common.
168-
169-
To customize the styles provided by this plugin, add your overrides under the `typography` key in the `theme` section of your `tailwind.config.js` file:
170-
171-
```js
172-
// tailwind.config.js
173-
module.exports = {
174-
theme: {
175-
extend: {
176-
typography: {
177-
DEFAULT: {
178-
css: {
179-
color: '#333',
180-
a: {
181-
color: '#3182ce',
182-
'&:hover': {
183-
color: '#2c5282',
184-
},
185-
},
186-
},
187-
},
188-
}
189-
},
190-
},
191-
plugins: [
192-
require('@tailwindcss/typography'),
193-
// ...
194-
],
195-
}
196-
```
197-
198-
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:
199-
200-
```js
201-
// tailwind.config.js
202-
module.exports = {
203-
theme: {
204-
extend: {
205-
typography: (theme) => ({
206-
DEFAULT: {
207-
css: {
208-
color: theme('colors.gray.800'),
209-
210-
// ...
211-
},
212-
},
213-
}),
214-
}
215-
},
216-
plugins: [
217-
require('@tailwindcss/typography'),
218-
// ...
219-
],
220-
}
221-
```
222-
223-
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](https://tailwindcss.com/docs/plugins#css-in-js-syntax) used to write Tailwind plugins.
224-
225-
It's important to note that all customizations are **merged** with the defaults. If you'd like to completely override a provided size modifier, you can do so by disabling that modifier so the default styles are not included.
226-
227-
See [the default styles](./src/styles.js) for this plugin for more in-depth examples of configuring each modifier.
228-
229-
### Customizing shared styles
230-
231-
Many styles _(for example colors, font weight, and text decoration)_ are shared between all size modifiers, and are therefore defined only for the `DEFAULT` modifier, since modifiers are designed to be used with the [multi-class modifier pattern](http://nicolasgallagher.com/about-html-semantics-front-end-architecture/#component-modifiers).
232-
233-
If you'd like to customize these sorts of styles, do so using the `DEFAULT` modifier:
234-
235-
```js
236-
// tailwind.config.js
237-
module.exports = {
238-
theme: {
239-
extend: {
240-
typography: {
241-
DEFAULT: {
242-
css: {
243-
color: '#333',
244-
strong: {
245-
fontWeight: '800',
246-
},
247-
// ...
248-
},
249-
},
250-
},
251-
}
252-
},
253-
plugins: [
254-
require('@tailwindcss/typography'),
255-
// ...
256-
],
257-
}
258-
```
259-
260-
### Adding new modifiers
261-
262-
You can add a new modifier by creating a new key in the `typography` section of your theme and providing your own styles under the `css` key:
263-
264-
```js
265-
// tailwind.config.js
266-
module.exports = {
267-
theme: {
268-
extend: {
269-
typography: {
270-
'3xl': {
271-
css: {
272-
fontSize: '1.875rem',
273-
h1: {
274-
fontSize: '4rem',
275-
},
276-
// ...
277-
},
278-
},
279-
},
280-
}
281-
},
282-
plugins: [
283-
require('@tailwindcss/typography'),
284-
// ...
285-
],
286-
}
287-
```
288-
289-
### Overriding max-width
290-
291-
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.
292-
293-
In those cases, all you need to do is add `max-w-none` to your content to override the embedded max-width:
294-
295-
```html
296-
<div class="grid grid-cols-4">
297-
<div class="col-span-1">
298-
<!-- ... -->
299-
</div>
300-
<div class="col-span-3">
301-
<article class="prose max-w-none">
302-
{{ markdown }}
303-
</article>
304-
</div>
305-
</div>
306-
```
307-
308-
### Disabling size modifiers
309-
310-
If you'd like to completely disable any size modifiers (either for file size reasons or because you'd like to completely redefine that modifier), you can do so using the `modifiers` option when including the plugin:
311-
312-
```js
313-
// tailwind.config.js
314-
module.exports = {
315-
theme: {
316-
// ...
317-
},
318-
plugins: [
319-
require('@tailwindcss/typography')({
320-
modifiers: ['sm', 'lg'],
321-
}),
322-
// ...
323-
],
324-
}
325-
```
326-
327-
This option acts as a _safelist_, so you can list only the modifiers you'd actually like included and the others will be removed.
328-
329-
The `DEFAULT` modifier is always included and cannot be disabled.
330-
331-
### Disabling responsive variants
332-
333-
If you'd like to disable the responsive variants for any reason, you can do so by setting the `typography` key to an empty array in the `variants` section of your `tailwind.config.js` file:
334-
335-
```js
336-
// tailwind.config.js
337-
module.exports = {
338-
theme: {
339-
// ...
340-
},
341-
plugins: [
342-
require('@tailwindcss/typography'),
343-
// ...
344-
],
345-
variants: {
346-
typography: [],
347-
},
348-
}
349-
```
350-
351-
352-
### Changing the default class name
353-
354-
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:
355-
356-
```js
357-
// tailwind.config.js
358-
module.exports = {
359-
theme: {
360-
// ...
361-
},
362-
plugins: [
363-
require('@tailwindcss/typography')({
364-
className: 'markdown',
365-
}),
366-
]
367-
...
368-
}
369-
```
370-
371-
```html
372-
<article class="markdown md:markdown-lg">
373-
{{ markdown }}
374-
</article>
375-
```
21+
[Join the Tailwind CSS Discord Server](https://tailwindcss.com/discord)

0 commit comments

Comments
 (0)