Test Artikel

Test Artikel

Posted by Sif

Until now, trying to style an article, docu­ment, or blog post with Tail­wind has been a tedious task that required a keen eye for typo­graphy and a lot of complex custom CSS.

By default, Tail­wind removes all of the default browser styling from para­graphs, head­ings, lists and more. This ends up being really useful for building applic­a­tion 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 mark­down file, it can be surprising and unin­tu­itive.

We get lots of complaints about it actu­ally, with people regu­larly asking us things like:

Why is Tail­wind 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?

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 dash­board 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.

The @tail­windcss/typo­graphy plugin is our attempt to give you what you actu­ally want, without any of the down­sides of doing some­thing stupid like disabling our base styles.

It adds a new prose class that you can slap on any block of vanilla HTML content and turn it into a beau­tiful, well-formatted docu­ment:

<article class="prose">
  <h1>Garlic bread with cheese: What the science tells us</h1>
  <p>
    For years parents have espoused the health bene­fits of eating garlic bread with cheese to their
    chil­dren, with the food earning such an iconic status in our culture that kids will often dress
    up as warm, cheesy loaf for Halloween.
  </p>
  <p>
    But a recent study shows that the celeb­rated appet­izer may be linked to a series of rabies cases
    springing up around the country.
  </p>
  <!-- ... -->
</article>

For more inform­a­tion about how to use the plugin and the features it includes, read the docu­ment­a­tion.


What to expect from here on out

What follows from here is just a bunch of abso­lute nonsense I've written to dogfood the plugin itself. It includes every sens­ible typo­graphic element I could think of, like bold text, unordered lists, ordered lists, code blocks, block quotes, and even italics.

It's important to cover all of these use cases for a few reasons:

  1. We want everything to look good out of the box.
  2. Really just the first reason, that's the whole point of the plugin.
  3. Here's a third pretend reason though a list with three items looks more real­istic than a list with two items.

Now we're going to try out another header style.

Typo­graphy should be easy

So that's a header for you — with any luck if we've done our job correctly that will look pretty reas­on­able.

Some­thing a wise person once told me about typo­graphy is:

Typo­graphy is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad.

It's prob­ably important that images look okay here by default as well:

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of clas­sical Latin liter­ature from 45 BC, making it over 2000 years old.

Now I'm going to show you an example of an unordered list to make sure that looks good, too:

  • So here is the first item in this list.
  • In this example we're keeping the items short.
  • Later, we'll use longer, more complex list items.

And that's the end of this section.

What if we stack head­ings?

We should make sure that looks good, too.

Some­times you have head­ings directly under­neath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the head­ings to be closer together than a para­graph followed by a heading should be.

When a heading comes after a para­graph …

When a heading comes after a para­graph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like.

  • I often do this thing where list items have head­ings.

    For some reason I think this looks cool which is unfor­tu­nate because it's pretty annoying to get the styles right.

    I often have two or three para­graphs in these list items, too, so the hard part is getting the spacing between the para­graphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argu­ment that you just shouldn't write this way.

  • Since this is a list, I need at least two items.

    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 real­istic. That's why I've added this second list item so I actu­ally have some­thing to look at when writing the styles.

  • It's not a bad idea to add a third item either.

    I think it prob­ably would've been fine to just use two items but three is defin­itely not worse, and since I seem to be having no trouble making up arbit­rary things to type, I might as well include it.

After this sort of list I usually have a closing state­ment or para­graph, because it kinda looks weird jumping right to a heading.

Aussichten

Miau miau bla bla