Skip to content

tailwindcss 排版神器

plugins: [
function ({ addUtilities }) {
const newUtilities = {
'.typography-h1': {
'@apply scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl': {},
},
'.typography-h2': {
'@apply scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0 mt-10': {},
},
'.typography-h3': {
'@apply scroll-m-20 text-2xl font-semibold tracking-tight mt-8': {},
},
'.typography-h4': {
'@apply scroll-m-20 text-xl font-semibold tracking-tight': {},
},
'.typography-p': {
'@apply leading-7 [&:not(:first-child)]:mt-6': {},
},
'.typography-blockquote': {
'@apply mt-6 border-l-2 pl-6 italic': {},
},
'.typography-ul': {
'@apply my-6 ml-6 list-disc [&>li]:mt-2': {},
},
'.typography-inline-code': {
'@apply relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold': {},
},
'.typography-lead': {
'@apply text-xl text-muted-foreground': {},
},
'.typography-large': {
'@apply text-lg font-semibold': {},
},
'.typography-small': {
'@apply text-sm font-medium leading-none': {},
},
'.typography-muted': {
'@apply text-sm text-muted-foreground': {},
},
'.typography-a': {
'@apply font-medium text-primary underline underline-offset-4': {},
},
'.typography-tr': {
'@apply m-0 border-t p-0 even:bg-muted': {},
},
'.typography-td': {
'@apply border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right': {},
},
'.typography-th': {
'@apply border px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right': {},
}
};
addUtilities(newUtilities, ['responsive', 'hover']);
},
],

React

typography

Vue

<template>
<div class="container max-w-[714px] p-10">
<h1 class="typography-h1">
The Joke Tax Chronicles
</h1>
<p class="typography-p">
Once upon a time, in a far-off land, there was a very lazy king who
spent all day lounging on his throne. One day, his advisors came to him
with a problem: the kingdom was running out of money.
</p>
<h2 class="typography-h2">
The King's Plan
</h2>
<p class="typography-p">
The king thought long and hard, and finally came up with
<a href="#" class="typography-a">
a brilliant plan
</a>
: he would tax the jokes in the kingdom.
</p>
<blockquote class="typography-blockquote">
"After all," he said, "everyone enjoys a good joke, so it's only fair
that they should pay for the privilege."
</blockquote>
<h3 class="typography-h3">
The Joke Tax
</h3>
<p class="typography-p">
The king's subjects were not amused. They grumbled and complained, but
the king was firm:
</p>
<ul class="typography-ul">
<li class="typography-li">1st level of puns: 5 gold coins</li>
<li class="typography-li">2nd level of jokes: 10 gold coins</li>
<li class="typography-li">3rd level of one-liners : 20 gold coins</li>
</ul>
<div class="my-6 w-full overflow-y-auto">
<table class="w-full">
<thead>
<tr class="typography-tr">
<th
class="typography-th">
King's Treasury
</th>
<th
class="typography-th">
People's happiness
</th>
</tr>
</thead>
<tbody>
<tr class="typography-tr">
<td
class="typography-td">
Empty
</td>
<td
class="typography-td">
Overflowing
</td>
</tr>
<tr class="typography-tr">
<td
class="typography-td">
Modest
</td>
<td
class="typography-td">
Satisfied
</td>
</tr>
<tr class="typography-tr">
<td
class="typography-td">
Full
</td>
<td
class="typography-td">
Ecstatic
</td>
</tr>
</tbody>
</table>
</div>
<p class="typography-p">
As a result, people stopped telling jokes, and the kingdom fell into a
gloom. But there was one person who refused to let the king's
foolishness get him down: a court jester named.
</p>
<h3 class="typography-h3">
Jokester's Revolt
</h3>
<p class="typography-p">
Jokester began sneaking into the castle in the middle of the night and
leaving jokes all over the place: under the king's pillow, in his soup,
even in the royal toilet. The king was furious, but he couldn't seem to
stop Jokester.
</p>
<p class="typography-p">
And then, one day, the people of the kingdom discovered that the jokes
left by Jokester were so funny that they couldn't help but laugh. And
once they started laughing, they couldn't stop.
</p>
<h3 class="typography-h3">
The People's Rebellion
</h3>
<p class="typography-p">
The people of the kingdom, feeling uplifted by the laughter, started to
tell jokes and puns again, and soon the entire kingdom was in on the
joke.
</p>
<p class="typography-p">
The king, seeing how much happier his subjects were, realized the error
of his ways and repealed the joke tax. Jokester was declared a hero, and
the kingdom lived happily ever after.
</p>
<p class="typography-p">
The moral of the story is: never underestimate the power of a good laugh
and always be careful of bad ideas.
</p>
</div>
</template>