Skip to content
This repository was archived by the owner on Feb 14, 2022. It is now read-only.

Commit 0676538

Browse files
committed
Publish Tailwind CSS Typography announcement
1 parent c10ae53 commit 0676538

File tree

5 files changed

+125
-138
lines changed

5 files changed

+125
-138
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@mapbox/rehype-prism": "^0.5.0",
1313
"@mdx-js/loader": "^1.6.6",
1414
"@next/mdx": "^9.4.4",
15+
"@tailwindcss/typography": "^0.1.1",
1516
"@tailwindcss/ui": "^0.3.0",
1617
"autoprefixer": "^9.8.4",
1718
"next": "9.4.4",
136 KB
Loading
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { adamwathan } from '@/authors'
2+
import image from './card.jpg'
3+
4+
export const meta = {
5+
title: 'Introducing Tailwind CSS Typography',
6+
description: `One of the things we believe as a team is that everything we make should be sealed with a blog post. Forcing ourselves to write up a short announcement post for every project we work on acts as a built-in quality check, making sure that we never call a project "done" until we feel comfortable telling the world it's out there. The problem was that up until today, we didn't actually have anywhere to publish those posts!`,
7+
date: '2020-07-13T16:35:02.037Z',
8+
authors: [adamwathan],
9+
image,
10+
// discussion: 'https://github.com/tailwindcss/tailwindcss/discussions/1987',
11+
}
12+
13+
<!--excerpt-->
14+
15+
Until now, trying to style an article, document, or blog post with Tailwind has been a tedious
16+
task that required a keen eye for typography and a lot of complex custom CSS.
17+
18+
That's why today we're excited to release [`@tailwindcss/typography`](https://github.com/tailwindcss/typography) a plugin that lets you easily style vanilla HTML content with beautiful typographic defaults.
19+
20+
<!--/excerpt-->
21+
22+
<p className="lead">
23+
Until now, trying to style an article, document, or blog post with Tailwind has been a tedious
24+
task that required a keen eye for typography and a lot of complex custom CSS.
25+
</p>
26+
27+
By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
28+
29+
We get lots of complaints about it actually, with people regularly asking us things like:
30+
31+
> Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
32+
33+
We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
34+
35+
That's why today we're excited to release [`@tailwindcss/typography`](https://github.com/tailwindcss/typography) — a plugin that gives you what you _actually_ want, without any of the downside of doing something stupid like disabling our base styles.
36+
37+
It adds a new set of `prose` classes that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
38+
39+
```html
40+
<article class="prose lg:prose-xl">
41+
<h1>Garlic bread with cheese: What the science tells us</h1>
42+
<p>
43+
For years parents have espoused the health benefits of eating garlic bread with cheese to their
44+
children, with the food earning such an iconic status in our culture that kids will often dress
45+
up as warm, cheesy loaf for Halloween.
46+
</p>
47+
<p>
48+
But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
49+
springing up around the country.
50+
</p>
51+
<!-- ... -->
52+
</article>
53+
```
54+
55+
So how does it actually look? Well you're looking at it right now — we use it to style the content on this very blog!
56+
57+
[**Check out the documentation**](https://github.com/tailwindcss/typography) to learn more and try it out today.

tailwind.config.js

Lines changed: 37 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,49 @@ module.exports = {
4646
white: '#fff',
4747
},
4848
},
49-
typography: {
50-
bullets: 'line',
51-
linkColor: [
52-
'#bada55',
53-
{
54-
hover: '#facade',
49+
typography: (theme) => ({
50+
default: {
51+
css: {
52+
color: theme('colors.gray.700'),
53+
h2: {
54+
fontWeight: '700',
55+
letterSpacing: theme('letterSpacing.tight'),
56+
color: theme('colors.gray.900'),
57+
},
58+
h3: {
59+
fontWeight: '600',
60+
color: theme('colors.gray.900'),
61+
},
62+
'ol li:before': {
63+
fontWeight: '600',
64+
color: theme('colors.gray.500'),
65+
},
66+
'ul li:before': {
67+
backgroundColor: theme('colors.gray.400'),
68+
},
69+
code: {
70+
color: theme('colors.gray.900'),
71+
},
72+
a: {
73+
color: theme('colors.gray.900'),
74+
},
75+
pre: {
76+
color: theme('colors.gray.200'),
77+
backgroundColor: theme('colors.gray.800'),
78+
},
79+
blockquote: {
80+
color: theme('colors.gray.900'),
81+
borderLeftColor: theme('colors.gray.200'),
82+
},
5583
},
56-
],
57-
},
84+
},
85+
}),
5886
},
5987
},
6088
variants: {},
6189
plugins: [
6290
require('@tailwindcss/ui'),
91+
require('@tailwindcss/typography'),
6392
function ({ addBase, addComponents, theme }) {
6493
addBase([
6594
{
@@ -83,136 +112,6 @@ module.exports = {
83112
},
84113
},
85114
])
86-
87-
addComponents({
88-
'.prose': {
89-
'> :first-child': {
90-
marginTop: '0',
91-
},
92-
'> :last-child': {
93-
marginBottom: '0',
94-
},
95-
96-
fontSize: theme('fontSize.base'),
97-
lineHeight: theme('lineHeight.7'),
98-
color: theme('colors.gray.700'),
99-
p: {
100-
marginTop: theme('spacing.5'),
101-
marginBottom: theme('spacing.5'),
102-
},
103-
h2: {
104-
marginTop: theme('spacing.12'),
105-
marginBottom: theme('spacing.6'),
106-
fontSize: theme('fontSize.2xl'),
107-
fontWeight: '700',
108-
lineHeight: theme('lineHeight.8'),
109-
letterSpacing: theme('letterSpacing.tight'), // Consider removing
110-
color: theme('colors.gray.900'),
111-
},
112-
h3: {
113-
marginTop: theme('spacing.8'),
114-
marginBottom: theme('spacing.3'),
115-
fontSize: theme('fontSize.xl'),
116-
fontWeight: '600',
117-
lineHeight: theme('lineHeight.8'),
118-
color: theme('colors.gray.900'),
119-
},
120-
'h3 + *': {
121-
marginTop: '0',
122-
},
123-
ol: {
124-
counterReset: 'list-counter',
125-
marginTop: theme('spacing.5'),
126-
marginBottom: theme('spacing.5'),
127-
},
128-
ul: {
129-
marginTop: theme('spacing.5'),
130-
marginBottom: theme('spacing.5'),
131-
},
132-
li: {
133-
marginTop: theme('spacing.2'),
134-
marginBottom: theme('spacing.2'),
135-
},
136-
'ol li': {
137-
position: 'relative',
138-
counterIncrement: 'list-counter',
139-
paddingLeft: theme('spacing.8'),
140-
},
141-
'ol li:before': {
142-
content: 'counter(list-counter) "."',
143-
position: 'absolute',
144-
left: '0',
145-
fontWeight: '600',
146-
color: theme('colors.gray.500'),
147-
},
148-
'ul li': {
149-
position: 'relative',
150-
paddingLeft: theme('spacing.8'),
151-
},
152-
'ul li:before': {
153-
content: '""',
154-
position: 'absolute',
155-
top: 'calc(0.875em - 0.0625em)',
156-
left: '0',
157-
backgroundColor: theme('colors.gray.400'),
158-
height: '0.125em',
159-
width: '0.75em',
160-
},
161-
img: {
162-
marginTop: theme('spacing.8'),
163-
marginBottom: theme('spacing.8'),
164-
},
165-
video: {
166-
marginTop: theme('spacing.8'),
167-
marginBottom: theme('spacing.8'),
168-
},
169-
figure: {
170-
marginTop: theme('spacing.8'),
171-
marginBottom: theme('spacing.8'),
172-
},
173-
code: {
174-
fontSize: theme('fontSize.sm'),
175-
lineHeight: theme('lineHeight.7'),
176-
fontFamily: theme('fontFamily.mono').join(', '),
177-
color: theme('colors.gray.700'),
178-
backgroundColor: theme('colors.gray.50'),
179-
borderColor: theme('colors.gray.200'),
180-
borderWidth: theme('borderWidth.default'),
181-
borderRadius: theme('borderRadius.md'),
182-
paddingTop: theme('spacing.1'),
183-
paddingRight: theme('spacing[1.5]'),
184-
paddingBottom: theme('spacing.1'),
185-
paddingLeft: theme('spacing[1.5]'),
186-
},
187-
a: {
188-
color: theme('colors.gray.900'),
189-
textDecoration: 'underline',
190-
},
191-
pre: {
192-
color: theme('colors.gray.200'),
193-
fontSize: theme('fontSize.sm'),
194-
fontFamily: theme('fontFamily.mono').join(', '),
195-
lineHeight: theme('lineHeight.6'),
196-
borderRadius: theme('borderRadius.md'),
197-
backgroundColor: theme('colors.gray.800'),
198-
paddingTop: theme('spacing.3'),
199-
paddingRight: theme('spacing.4'),
200-
paddingBottom: theme('spacing.3'),
201-
paddingLeft: theme('spacing.4'),
202-
overflowX: 'auto',
203-
},
204-
'pre code': {
205-
backgroundColor: 'transparent',
206-
borderWidth: '0',
207-
borderRadius: '0',
208-
padding: '0',
209-
color: 'inherit',
210-
fontSize: 'inherit',
211-
fontFamily: 'inherit',
212-
lineHeight: 'inherit',
213-
},
214-
},
215-
})
216115
},
217116
],
218117
}

yarn.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,11 @@
11371137
mini-svg-data-uri "^1.0.3"
11381138
traverse "^0.6.6"
11391139

1140+
"@tailwindcss/typography@^0.1.1":
1141+
version "0.1.1"
1142+
resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.1.1.tgz#b38c79765e17bfa2390304cbc3ce71120a0b8326"
1143+
integrity sha512-CIxGZtU13VK/+EUE6wsb3d7xze0FAX6HiN8r1r3xWQQ3Hawbw1ahCPUBG9mBZW4OlJeZfEz3101yhXr0cllX0Q==
1144+
11401145
"@tailwindcss/ui@^0.3.0":
11411146
version "0.3.0"
11421147
resolved "https://registry.yarnpkg.com/@tailwindcss/ui/-/ui-0.3.0.tgz#846e489c61bdeb60bdd4e2c32033db770ad8d429"
@@ -4203,6 +4208,18 @@ mime-db@1.44.0:
42034208
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92"
42044209
integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==
42054210

4211+
mime-db@~1.25.0:
4212+
version "1.25.0"
4213+
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.25.0.tgz#c18dbd7c73a5dbf6f44a024dc0d165a1e7b1c392"
4214+
integrity sha1-wY29fHOl2/b0SgJNwNFloeexw5I=
4215+
4216+
mime-types@2.1.13:
4217+
version "2.1.13"
4218+
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.13.tgz#e07aaa9c6c6b9a7ca3012c69003ad25a39e92a88"
4219+
integrity sha1-4HqqnGxrmnyjASxpADrSWjnpKog=
4220+
dependencies:
4221+
mime-db "~1.25.0"
4222+
42064223
mime-types@~2.1.24:
42074224
version "2.1.27"
42084225
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f"
@@ -5715,6 +5732,14 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
57155732
hash-base "^3.0.0"
57165733
inherits "^2.0.1"
57175734

5735+
rss@^1.2.2:
5736+
version "1.2.2"
5737+
resolved "https://registry.yarnpkg.com/rss/-/rss-1.2.2.tgz#50a1698876138133a74f9a05d2bdc8db8d27a921"
5738+
integrity sha1-UKFpiHYTgTOnT5oF0r3I240nqSE=
5739+
dependencies:
5740+
mime-types "2.1.13"
5741+
xml "1.0.1"
5742+
57185743
run-queue@^1.0.0, run-queue@^1.0.3:
57195744
version "1.0.3"
57205745
resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47"
@@ -6865,6 +6890,11 @@ ws@^6.0.0:
68656890
dependencies:
68666891
async-limiter "~1.0.0"
68676892

6893+
xml@1.0.1:
6894+
version "1.0.1"
6895+
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
6896+
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=
6897+
68686898
xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.1:
68696899
version "4.0.2"
68706900
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"

0 commit comments

Comments
 (0)