-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
484 lines (479 loc) · 20.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<!DOCTYPE html>
<html lang="en">
<head prefix="og: https://ogp.me/ns#">
<title>Typography should be easy. - Shiraha</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>
window.shiraha = { colors: { brightnessSuffix: false } };
</script>
<link rel="stylesheet" href="https://shiraha.js.org/nightly/shiraha.css" />
<link rel="stylesheet" href="https://shiraha.js.org/nightly/themes/baseline-tone-based.css" />
<link rel="stylesheet" href="https://shiraha.js.org/nightly/addons/chip.css" />
<link rel="stylesheet" href="https://shiraha.js.org/nightly/addons/code_starry-night.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" />
<link rel="stylesheet" href="https://esm.sh/@wooorm/starry-night@1/style/both.css" />
<!-- Normal -->
<script type="module" src="/src/index.ts" async></script>
</head>
<body>
<nav>
<ol>
<span class="material-symbols-outlined">chevron_left</span>
<li>
<a href="/lume_theme_shiraha/">Shiraha</a>
</li>
</ol>
</nav>
<main>
<article class="h-entry">
<h1 class="p-name">Typography should be easy.</h1>
<p class="chip-container-wrap">
<a class="h-card p-author u-url chip chip-tonal"
href="https://github.com/tailwindlabs/tailwindcss-typography/blob/master/demo/components/MarkdownSample.mdx">
<img src="https://avatars.githubusercontent.com/u/67109815" alt="TailwindCSS" class="u-photo" />
<span>TailwindCSS</span>
</a>
<span class="chip chip-tonal">
<span class="material-symbols-outlined">calendar_month</span>
<time class="dt-published" datetime="2023-05-29"> 2023-05-29 </time>
</span>
</p>
<div class="e-content">
<p classname="lead">
Until now, trying to style an article, document, or blog post with
Tailwind has been a tedious task that required a keen eye for
typography and a lot of complex custom CSS.
</p>
<p>
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 <em>really are</em> 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.
</p>
<p>
We get lots of complaints about it actually, with people regularly
asking us things like:
</p>
<blockquote>
<p>
Why is Tailwind removing the default styles on my
<code>h1</code> elements? How do I disable this? What do you mean
I lose all the other base styles too?
</p>
</blockquote>
<p>
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 <code>p</code> 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
<em>awesome</em>, not awful.
</p>
<p>
The <code>@tailwindcss/typography</code> plugin is our attempt to
give you what you <em>actually</em> want, without any of the
downsides of doing something stupid like disabling our base styles.
</p>
<p>
It adds a new <code>prose</code> class that you can slap on any
block of vanilla HTML content and turn it into a beautiful,
well-formatted document:
</p>
<div class="highlight highlight-html">
<div class="highlight-header">
<div class="highlight-language">html</div>
</div>
<pre><code tabindex="0"><span class="line"><span class="line-number" aria-hidden="true"> 1</span><<span class="pl-ent">article</span> <span class="pl-e">class</span>=<span class="pl-s"><span class="pl-pds">"</span>prose<span class="pl-pds">"</span></span>></span>
<span class="line"><span class="line-number" aria-hidden="true"> 2</span> <<span class="pl-ent">h1</span>>Garlic bread with cheese: What the science tells us</<span class="pl-ent">h1</span>></span>
<span class="line"><span class="line-number" aria-hidden="true"> 3</span> <<span class="pl-ent">p</span>></span>
<span class="line"><span class="line-number" aria-hidden="true"> 4</span> For years parents have espoused the health benefits of eating garlic bread with cheese to their</span>
<span class="line"><span class="line-number" aria-hidden="true"> 5</span> children, with the food earning such an iconic status in our culture that kids will often dress</span>
<span class="line"><span class="line-number" aria-hidden="true"> 6</span> up as warm, cheesy loaf for Halloween.</span>
<span class="line"><span class="line-number" aria-hidden="true"> 7</span> </<span class="pl-ent">p</span>></span>
<span class="line"><span class="line-number" aria-hidden="true"> 8</span> <<span class="pl-ent">p</span>></span>
<span class="line"><span class="line-number" aria-hidden="true"> 9</span> But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases</span>
<span class="line"><span class="line-number" aria-hidden="true">10</span> springing up around the country.</span>
<span class="line"><span class="line-number" aria-hidden="true">11</span> </<span class="pl-ent">p</span>></span>
<span class="line"><span class="line-number" aria-hidden="true">12</span> <span class="pl-c"><!-- ... --></span></span>
<span class="line"><span class="line-number" aria-hidden="true">13</span></<span class="pl-ent">article</span>></span>
</code></pre>
</div>
<p>
For more information about how to use the plugin and the features it
includes,
<a href="https://github.com/tailwindcss/typography/blob/master/README.md">read the documentation</a>.
</p>
<hr />
<h2>What to expect from here on out</h2>
<p>
What follows from here is just a bunch of absolute nonsense I've
written to dogfood the plugin itself. It includes every sensible
typographic element I could think of, like
<strong>bold text</strong>, unordered lists, ordered lists, code
blocks, block quotes, <em>and even italics</em>.
</p>
<p>
It's important to cover all of these use cases for a few reasons:
</p>
<ol>
<li>We want everything to look good out of the box.</li>
<li>
Really just the first reason, that's the whole point of the
plugin.
</li>
<li>
Here's a third pretend reason though a list with three items looks
more realistic than a list with two items.
</li>
</ol>
<p>Now we're going to try out another header style.</p>
<h3>Typography should be easy</h3>
<p>
So that's a header for you — with any luck if we've done our job
correctly that will look pretty reasonable.
</p>
<p>Something a wise person once told me about typography is:</p>
<blockquote>
<p>
Typography is pretty important if you don't want your stuff to
look like trash. Make it good then it won't be bad.
</p>
</blockquote>
<p>
It's probably important that images look okay here by default as
well:
</p>
<figure>
<img
src="https://images.unsplash.com/photo-1556740758-90de374c12ad?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80"
alt="" />
<figcaption>
Contrary to popular belief, Lorem Ipsum is not simply random text.
It has roots in a piece of classical Latin literature from 45 BC,
making it over 2000 years old.
</figcaption>
</figure>
<p>
Now I'm going to show you an example of an unordered list to make
sure that looks good, too:
</p>
<ul>
<li>So here is the first item in this list.</li>
<li>In this example we're keeping the items short.</li>
<li>Later, we'll use longer, more complex list items.</li>
</ul>
<p>And that's the end of this section.</p>
<h2>What if we stack headings?</h2>
<h3>We should make sure that looks good, too.</h3>
<p>
Sometimes you have headings directly underneath each other. In those
cases you often have to undo the top margin on the second heading
because it usually looks better for the headings to be closer
together than a paragraph followed by a heading should be.
</p>
<h3>When a heading comes after a paragraph …</h3>
<p>
When a heading comes after a paragraph, we need a bit more space,
like I already mentioned above. Now let's see what a more complex
list would look like.
</p>
<ul>
<li>
<p>
<strong>I often do this thing where list items have headings.</strong>
</p>
<p>
For some reason I think this looks cool which is unfortunate
because it's pretty annoying to get the styles right.
</p>
<p>
I often have two or three paragraphs in these list items, too,
so the hard part is getting the spacing between the paragraphs,
list item heading, and separate list items to all make sense.
Pretty tough honestly, you could make a strong argument that you
just shouldn't write this way.
</p>
</li>
<li>
<p>
<strong>Since this is a list, I need at least two items.</strong>
</p>
<p>
I explained what I'm doing already in the previous list item,
but a list wouldn't be a list if it only had one item, and we
really want this to look realistic. That's why I've added this
second list item so I actually have something to look at when
writing the styles.
</p>
</li>
<li>
<p>
<strong>It's not a bad idea to add a third item either.</strong>
</p>
<p>
I think it probably would've been fine to just use two items but
three is definitely not worse, and since I seem to be having no
trouble making up arbitrary things to type, I might as well
include it.
</p>
</li>
</ul>
<p>
After this sort of list I usually have a closing statement or
paragraph, because it kinda looks weird jumping right to a heading.
</p>
<h2>Code should look okay by default.</h2>
<p>
I think most people are going to use
<a href="https://highlightjs.org/">highlight.js</a> or
<a href="https://prismjs.com/">Prism</a> or something if they want
to style their code blocks but it wouldn't hurt to make them look
<em>okay</em> out of the box, even with no syntax highlighting.
</p>
<p>
Here's what a default <code>tailwind.config.js</code> file looks
like at the time of writing:
</p>
<div class="highlight highlight-js">
<div class="highlight-header">
<div class="highlight-language">js</div>
</div>
<pre><code tabindex="0"><span class="line"><span class="line-number" aria-hidden="true">1</span><span class="pl-c1">module</span>.<span class="pl-smi">exports</span> <span class="pl-k">=</span> {</span>
<span class="line"><span class="line-number" aria-hidden="true">2</span> purge<span class="pl-k">:</span> [],</span>
<span class="line"><span class="line-number" aria-hidden="true">3</span> theme<span class="pl-k">:</span> {</span>
<span class="line"><span class="line-number" aria-hidden="true">4</span> extend<span class="pl-k">:</span> {},</span>
<span class="line"><span class="line-number" aria-hidden="true">5</span> },</span>
<span class="line"><span class="line-number" aria-hidden="true">6</span> variants<span class="pl-k">:</span> {},</span>
<span class="line"><span class="line-number" aria-hidden="true">7</span> plugins<span class="pl-k">:</span> [],</span>
<span class="line"><span class="line-number" aria-hidden="true">8</span>}</span>
</code></pre>
</div>
<p>Hopefully that looks good enough to you.</p>
<h3>What about nested lists?</h3>
<p>
Nested lists basically always look bad which is why editors like
Medium don't even let you do it, but I guess since some of you
goofballs are going to do it we have to carry the burden of at least
making it work.
</p>
<ol>
<li>
<strong>Nested lists are rarely a good idea.</strong>
<ul>
<li>
You might feel like you are being really "organized" or
something but you are just creating a gross shape on the
screen that is hard to read.
</li>
<li>
Nested navigation in UIs is a bad idea too, keep things as
flat as possible.
</li>
<li>
Nesting tons of folders in your source code is also not
helpful.
</li>
</ul>
</li>
<li>
<strong>Since we need to have more items, here's another one.</strong>
<ul>
<li>
I'm not sure if we'll bother styling more than two levels
deep.
</li>
<li>
Two is already too much, three is guaranteed to be a bad idea.
</li>
<li>If you nest four levels deep you belong in prison.</li>
</ul>
</li>
<li>
<strong>Two items isn't really a list, three is good though.</strong>
<ul>
<li>
Again please don't nest lists if you want people to actually
read your content.
</li>
<li>Nobody wants to look at this.</li>
<li>I'm upset that we even have to bother styling this.</li>
</ul>
</li>
</ol>
<p>
The most annoying thing about lists in Markdown is that
<code><li></code> elements aren't given a child
<code><p></code> tag unless there are multiple paragraphs in
the list item. That means I have to worry about styling that
annoying situation too.
</p>
<ul>
<li>
<p><strong>For example, here's another nested list.</strong></p>
<p>But this time with a second paragraph.</p>
<ul>
<li>These list items won't have <code><p></code> tags</li>
<li>Because they are only one line each</li>
</ul>
</li>
<li>
<p>
<strong>But in this second top-level list item, they will.</strong>
</p>
<p>
This is especially annoying because of the spacing on this
paragraph.
</p>
<ul>
<li>
<p>
As you can see here, because I've added a second line, this
list item now has a <code><p></code> tag.
</p>
<p>This is the second line I'm talking about by the way.</p>
</li>
<li>
<p>
Finally here's another list item so it's more like a list.
</p>
</li>
</ul>
</li>
<li>
<p>
A closing list item, but with no nested list, because why not?
</p>
</li>
</ul>
<p>And finally a sentence to close off this section.</p>
<h2>There are other elements we need to style</h2>
<p>
I almost forgot to mention links, like
<a href="https://tailwindcss.com">this link to the Tailwind CSS website</a>. We almost made them blue but
that's so yesterday, so we went with
dark gray, feels edgier.
</p>
<p>We even included table styles, check it out:</p>
<table>
<thead>
<tr>
<th>Wrestler</th>
<th>Origin</th>
<th>Finisher</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bret "The Hitman" Hart</td>
<td>Calgary, AB</td>
<td>Sharpshooter</td>
</tr>
<tr>
<td>Stone Cold Steve Austin</td>
<td>Austin, TX</td>
<td>Stone Cold Stunner</td>
</tr>
<tr>
<td>Randy Savage</td>
<td>Sarasota, FL</td>
<td>Elbow Drop</td>
</tr>
<tr>
<td>Vader</td>
<td>Boulder, CO</td>
<td>Vader Bomb</td>
</tr>
<tr>
<td>Razor Ramon</td>
<td>Chuluota, FL</td>
<td>Razor's Edge</td>
</tr>
</tbody>
</table>
<p>
We also need to make sure inline code looks good, like if I wanted
to talk about <code><span></code> elements or tell you the
good news about <code>@tailwindcss/typography</code>.
</p>
<h3>Sometimes I even use <code>code</code> in headings</h3>
<p>
Even though it's probably a bad idea, and historically I've had a
hard time making it look good. This
<em>"wrap the code blocks in backticks"</em> trick works pretty well
though really.
</p>
<p>
Another thing I've done in the past is put a <code>code</code> tag
inside of a link, like if I wanted to tell you about the
<a href="https://github.com/tailwindcss/docs"><code>tailwindcss/docs</code></a>
repository. I don't love that there is an underline below the
backticks but it is absolutely not worth the madness it would
require to avoid it.
</p>
<h4>We haven't used an <code>h4</code> yet</h4>
<p>
But now we have. Please don't use <code>h5</code> or
<code>h6</code> in your content, Medium only supports two heading
levels for a reason, you animals. I honestly considered using a
<code>before</code> pseudo-element to scream at you if you use an
<code>h5</code> or <code>h6</code>.
</p>
<p>
We don't style them at all out of the box because
<code>h4</code> elements are already so small that they are the same
size as the body copy. What are we supposed to do with an
<code>h5</code>, make it <em>smaller</em> than the body copy? No
thanks.
</p>
<h3>We still need to think about stacked headings though.</h3>
<h4>
Let's make sure we don't screw that up with
<code>h4</code> elements, either.
</h4>
<p>
Phew, with any luck we have styled the headings above this text and
they look pretty good.
</p>
<p>
Let's add a closing paragraph here so things end with a decently
sized block of text. I can't explain why I want things to end that
way but I have to assume it's because I think things will look weird
or unbalanced if there is a heading too close to the end of the
document.
</p>
<p>
What I've written here is probably long enough, but adding this
final sentence can't hurt.
</p>
</div>
<p class="chip-container-wrap">
<span class="chip chip-tonal">
<span class="material-symbols-outlined">tag</span>
<a href="/lume_theme_shiraha/t/TailwindCSS" class="p-category">TailwindCSS</a>
</span>
</p>
</article>
<nav>
<ul>
<li>
<a role="button" href="/lume_theme_shiraha/articles/part-1-installation/" rel="next">Part 1: Installation
→</a>
</li>
</ul>
</nav>
</main>
<footer>
<p>
<span>© TailwindCSS</span>
<span>·</span>
<span>Powered by</span>
<a href="https://github.com/importantimport/lume_theme_shiraha">Lume Theme Shiraha</a>
<span>|</span>
<a href="/lume_theme_shiraha/feed.json">Feed</a>
</p>
</footer>
</body>
</html>