Estilos

Color

Color de interacción

El azul es el color principal de interacción, presente en los botones primarios y links.

Primary
Información
primary-light

#d6eaf0
primary-base

#00607a
primary-dark

#00475C
Show code
<div class="grid grid-cols-6 gap-5 mb-sm">
  <div class="col-span-3 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-primary-base text-white"><div class="self-center text-center w-full">Primary</div></div>
  </div>
  <div class="flex col-span-3 lg:col-span-2">
    <div class="self-center text-sm">Información</div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-primary-light text-black"><div class="self-center text-center w-full">primary-light <br><br>#d6eaf0</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-primary-base text-white"><div class="self-center text-center w-full">primary-base <br><br>#00607a</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-primary-dark font-semibold text-white"><div class="self-center text-center w-full">primary-dark <br><br>#00475C</div></div>
  </div>
</div>

Colores de soporte

Son los colores utilizados para diversos usos.

Warning
Focus
Aviso de precaución
En espera
warning-light

#fef6b2
warning-base

#fdcb33
warning-dark

#b88e12
Success
Confirmación
Publicado
Correcto
success-light

#dcf8e2
success-base

#24d14c
success-dark

#1aa23a
Info
info-light

#feebcc
info-base

#fa9902
info-dark

#c97a00
Alert
alert-light

#fbd3ce
alert-base

#d22333
alert-dark

#a40014
Show code
<div class="grid grid-cols-6 gap-5 mb-sm">
  <div class="col-span-3 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-alert-base text-white"><div class="self-center text-center w-full">Alert</div></div>
  </div>
  <div class="flex col-span-3 lg:col-span-2">
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-alert-light text-black"><div class="self-center text-center w-full">alert-light <br><br>#fbd3ce</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-alert-base text-white"><div class="self-center text-center w-full">alert-base <br><br>#d22333</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-alert-dark font-semibold text-white"><div class="self-center text-center w-full">alert-dark <br><br>#a40014</div></div>
  </div>
</div>

Colores neutros

Utiliza negro para los textos principales, neutral-dark para los textos secundarios, neutral-base para bordes de tarjetas y placeholders, neutral-light y neutral-lighter para fondos.

Black
Focus
Aviso de precaución
En espera
neutral-lighter

#f6f6f5
neutral-light

#ededec
neutral-base

#92949B
neutral-dark

#5e616b
black

#1f2331
Show code
<div class="grid grid-cols-8 gap-5 mb-sm">
  <div class="col-span-4 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-black text-white"><div class="self-center text-center w-full">Black</div></div>
  </div>
  <div class="flex col-span-4 lg:col-span-2">
    <div class="self-center text-sm">
      Focus <br>
      Aviso de precaución <br>
      En espera
    </div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-neutral-lighter text-black"><div class="self-center text-center w-full">neutral-lighter <br><br>#f6f6f5</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-neutral-light text-black"><div class="self-center text-center w-full">neutral-light <br><br>#ededec</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-neutral-base text-black"><div class="self-center text-center w-full">neutral-base <br><br>#92949B</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-neutral-dark text-white"><div class="self-center text-center w-full">neutral-dark <br><br>#5e616b</div></div>
  </div>
  <div class="col-span-2 lg:col-span-1 aspect-w-1 aspect-h-1 relative rounded overflow-hidden">
    <div class="absolute flex inset-0 bg-black text-white"><div class="self-center text-center w-full">black <br><br>#1f2331</div></div>
  </div>
</div>

Border

Utiliza línea sólida con grosor 1px en black o neutral-base.

black 1px

Bordes de campos de texto
Cabecera de tablas

neutral-base 1px

Separadores de contenidos
Bordes de tarjetas
Bordes de menus desplegables

alert-base 1px

Mensajes de error
Borde de campos de texto

black 4px

Mensajes de error
Borde de campos de texto

neutral-base 4px

Mensajes de información
algunos detalles de estados activosa
campos condicionales

alert-base 4px

Mensajes de información
algunos detalles de estados activos

primary-base 4px

Mensajes de información
algunos detalles de estados activos

Show code
<div class="grid grid-cols-4 gap-5 mb-sm">
  <div class="border-l border-black px-4">
    <p>black 1px</p>
    <p class="text-neutral-dark text-sm">Bordes de campos de texto <br>
                                         Cabecera de tablas</p>
  </div>
  <div class="border-l border-neutral-base px-4">
    <p>neutral-base 1px</p>
    <p class="text-neutral-dark text-sm">Separadores de contenidos <br>
                                         Bordes de tarjetas <br>
                                         Bordes de menus desplegables</p>
  </div>
  <div class="border-l border-alert-base px-4">
    <p>alert-base 1px</p>
    <p class="text-neutral-dark text-sm">Mensajes de error <br>
                                         Borde de campos de texto </p>
  </div>
  <div></div>
  <div class="border-l-4 border-black px-4">
    <p>black 4px</p>
    <p class="text-neutral-dark text-sm">Mensajes de error <br>
                                         Borde de campos de texto </p>
  </div>
  <div class="border-l-4 border-neutral-base px-4">
    <p>neutral-base 4px</p>
    <p class="text-neutral-dark text-sm">Mensajes de información <br>
                                         algunos detalles de estados activosa<br>
                                         campos condicionales</p>
  </div>
  <div class="border-l-4 border-alert-base px-4">
    <p>alert-base 4px</p>
    <p class="text-neutral-dark text-sm">Mensajes de información <br>
                                         algunos detalles de estados activos </p>
  </div>
  <div class="border-l-4 border-primary-base px-4">
    <p>primary-base 4px</p>
    <p class="text-neutral-dark text-sm">Mensajes de información <br>
                                         algunos detalles de estados activos </p>
  </div>
</div>

Accesibilidad de los colores

El contraste de color entre el texto y los elementos interactivos debe cumplir el mínimo AA de WCAG para herramientas internas del gobierno y AAA para herramientas a las que tenga acceso la ciudadanía.

El texto sobre masa de color en principio solo se usa en los botones principales, pero en caso de usarse, el peso de fuente debe ser Semibold y un tamaño mínimo de texto de 16px.

Texto
Texto
Texto
Texto
Texto

En los mensajes destacados utiliza los colores claros con texto negro.

Texto
Texto
Texto
Texto
Texto

Espaciado

Espaciado preferido de desy-html

Utiliza en la medida de lo posible estos valores, que se aplicarán automáticamente por Tailwind a height, max-height, margin, padding, gap e inset.

Nombre Tamaño Pixels Ejemplo de clases
xs 0.25rem 4px pr-xs
sm 0.5rem 8px pr-sm
base 1rem 16px pr-base
lg 1.75rem 28px pr-lg
xl 2.5rem 40px pr-xl
2xl 5rem 80px pr-2xl
3xl 10rem 160px pr-3xl

Espaciado preferido de desy-html para width

Utiliza en la medida de lo posible estos valores para establecer valores de width y max-width.

Nombre Tamaño Pixels Ejemplo de clases
xs 20rem 320px w-xs
sm 24rem 384px w-sm
md 28rem 448px w-md
lg 32rem 512px w-lg
xl 36rem 576px w-xl

Espaciado adicional de desy-html para max-width y max-height

desy-html usa los valores de Tailwind y adicionalmente estos otros:

Nombre Tamaño Pixels Ejemplo de clases
40 10rem 160px max-w-40
64 16rem 256px max-w-64

Espaciado por defecto de Tailwind CSS

Nombre Tamaño Pixels
0 0px 0px
px 1px 1px
0.5 0.125rem 2px
1 0.25rem 4px
1.5 0.375rem 6px
2 0.5rem 8px
2.5 0.625rem 10px
3 0.75rem 12px
3.5 0.875rem 14px
4 1rem 16px
5 1.25rem 20px
6 1.5rem 24px
7 1.75rem 28px
8 2rem 32px
9 2.25rem 36px
10 2.5rem 40px
11 2.75rem 44px
12 3rem 48px
14 3.5rem 56px
16 4rem 64px
20 5rem 80px
24 6rem 96px
28 7rem 112px
32 8rem 128px
36 9rem 144px
40 10rem 160px
44 11rem 176px
48 12rem 192px
52 13rem 208px
56 14rem 224px
60 15rem 240px
64 16rem 256px
72 18rem 288px
80 20rem 320px
96 24rem 384px

Layout

Tamaño de pantalla

Diseñamos para un tamaño de pantalla mínimo de 1024px correspondiente a nuestro breakpoint lg con un contenedor centrado y de anchura máxima 1280px, correspondiente a nuestras clases container mx-auto px-base.

Comienza diseñando para dispositivos móviles o pantallas pequeñas, resuelve su navegación con las opciones que te da el componente header y luego reposiciona los elementos para anchuras mayores. Tenemos configurados varios saltos de breakpoint, pero recomendamos usar sólo el breakpoint por defecto y el lg.

Breakpoints:

Columnas

Usamos un sistema basado en 4 columnas, con un espacio de gap-xl - 2.5rem - 40px / 16px. Utiliza las combinaciones reflejadas a continuación. Evita utilizar el layout a una columna (100%) para textos en pantallas de gran tamaño, afectaría negativamente a la legibilidad.

Pantallas grandes - escritorio

100%
50%
50%
75%
25%
25%
75%
25%
25%
25%
25%

Pantallas pequeñas - mobile

100%
50%
50%

En móviles utilizamos solo 2 combinaciones:

  • una columna (100%)
  • dos columnas (50% + 50%)
Show code
<div class="grid grid-cols-2 lg:grid-cols-4 gap-xl mt-base">
    <div class="col-span-2 lg:col-span-4 bg-neutral-light h-12 flex items-center justify-center">100%</div>
    <div class="col-span-1 lg:col-span-2 bg-neutral-light h-12 flex items-center justify-center">50%</div>
    <div class="col-span-1 lg:col-span-2 bg-neutral-light h-12 flex items-center justify-center">50%</div>
    <div class="col-span-1 lg:col-span-1 bg-neutral-light h-12 flex items-center justify-center">25%</div>
    <div class="col-span-1 lg:col-span-1 bg-neutral-light h-12 flex items-center justify-center">25%</div>
    <div class="col-span-1 lg:col-span-1 bg-neutral-light h-12 flex items-center justify-center">25%</div>
    <div class="col-span-1 lg:col-span-1 bg-neutral-light h-12 flex items-center justify-center">25%</div>
</div>

Textos

Fuentes

La tipografía principal es Open Sans en sus pesos Bold, Semibold y Regular.

Títulos

Título 1 (h1)

.c-h1 - bold - black - font-size: .text-3xl - 1.875rem - 30px - line-height: .leading-tight - 1.25 - 20px - margin-bottom: .mb-lg - 1.75 - 28px

Título 2 (h2)

.c-h2 - bold - black - font-size: .text-2xl - 1.5rem - 24px - line-height: .leading-tight - 1.25 - 20px - margin-bottom: .mb-base - 1 - 16px

Título 3 (h3)

.c-h3 - bold - black - font-size: .text-lg - 1.125rem - 18px - line-height: .leading-tight - 1.25 - 20px - margin-bottom: .mb-sm - 0.5 - 8px

Enlaces

Esto es un link en un texto.

.c-link - normal - underline - primary-base - hover: primary-dark

Esto es un link en una notificación de error.

.c-link.c-link--alert - normal - underline - alert-base - hover: alert-dark

Párrafos

Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.

Párrafo destacados.
.c-paragraph-lg
normal - black
font-size: .text-lg - 1.125rem - 18px
line-height: 1.75rem - 28px
margin-bottom: .mb-lg - 1.75rem - 28px

Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.

Párrafo por defecto.
.c-paragraph-base
normal - black
font-size: .text-base - 1rem - 16px
line-height: 1.5rem - 24px
margin-bottom: .mb-base - 1rem - 16px

Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.

Párrafo secundario.
.c-paragraph-base.text-neutral-dark
normal - neutral-dark
font-size: .text-base - 1rem - 16px
line-height: 1.5rem - 24px
margin-bottom: .mb-base - 1rem - 16px

Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.

Párrafo pequeño.
.c-paragraph-sm
normal - black
font-size: .text-sm - .875rem - 14px
line-height: 1.25rem - 20px
margin-bottom: .mb-sm - .625rem - 10px

Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.

Párrafo pequeño secundario.
.c-paragraph-sm.text-neutral-dark
normal - neutral-dark
font-size: .text-sm - .875rem - 14px
line-height: 1.25rem - 20px
margin-bottom: .mb-sm - .625rem - 10px

  • Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.
  • Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.
  • Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.

Lista.
.c-ul

  • Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.
  • Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.
  • Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa.

Lista ordenada.
.c-ol

Show code
<h1 class="c-h1">Título 1</h1>
<h2 class="c-h2">Título 2</h2>
<h2 class="c-h3">Título 3</h2>
<p>Esto es un <a href="#" class="c-link">link</a> en un texto</p>
<p>Esto es un <a href="#" class="c-link c-link--alert">link</a> en una notificación de error</p>
<p class="c-paragraph-lg">Párrafo destacados</p>
<p class="c-paragraph-base">Párrafo por defecto</p>
<p class="c-paragraph-base text-neutral-dark">Párrafo secundario</p>
<p class="c-paragraph-sm">Párrafo pequeño</p>
<p class="c-paragraph-sm text-neutral-dark">Párrafo pequeño secundario</p>
<ul class="c-ul">
  <li>Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. </li>
  <li>Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. </li>
  <li>Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. </li>
</ul>
<ul class="c-ol">
  <li>Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. </li>
  <li>Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. </li>
  <li>Nam dapibus nisl vitae elit fringilla rutrum. Aenean sollicitudin, erat a elementum rutrum, neque sem pretium metus, quis mollis nisl nunc et massa. </li>
</ul>

Tipografía en texto renderizado

Tailwindcss typography plugin

Para dar estilos por defecto a contenido html sin clases que proviene de markdown o de wysiwyg, utilizamos un plugin de Tailwindcss: tailwindcss-typography. Basta con añadir al contenedor la clase .prose. También hay variantes de estos estilos que pueden usarse con breakpoints, por ejemplo: prose-sm lg:prose max-w-none lg:max-w-none mx-auto. Leer la documentación.

Ejemplo:

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.

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.

We get lots of complaints about it actually, with people regularly asking us things like:

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?

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.

The @tailwindcss/typography plugin is our attempt to give you what you actually want, without any of the downsides of doing something 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 beautiful, well-formatted document:

<article class="prose">
    <h1>Garlic bread with cheese: What the science tells us</h1>
    <p>
      For years parents have espoused the health benefits of eating garlic bread with cheese to their
      children, 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 celebrated appetizer may be linked to a series of rabies cases
      springing up around the country.
    </p>
    <!-- ... -->
  </article>
  

For more information about how to use the plugin and the features it includes, read the documentation.


What to expect from here on out

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 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 realistic than a list with two items.

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

Typography should be easy

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

Something a wise person once told me about typography is:

Typography 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 probably 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 classical Latin literature 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 headings?

We should make sure that looks good, too.

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.

When a heading comes after a paragraph …

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.

  • I often do this thing where list items have headings.

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

    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.

  • 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 realistic. That's why I've added this second list item so I actually have something to look at when writing the styles.

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

    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.

After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.

Code should look okay by default.

I think most people are going to use highlight.js or Prism or something if they want to style their code blocks but it wouldn't hurt to make them look okay out of the box, even with no syntax highlighting.

Here's what a default tailwind.config.js file looks like at the time of writing:

module.exports = {
    purge: [],
    theme: {
      extend: {},
    },
    variants: {},
    plugins: [],
  }
  

Hopefully that looks good enough to you.

What about nested lists?

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.

  1. Nested lists are rarely a good idea.
    • 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.
    • Nested navigation in UIs is a bad idea too, keep things as flat as possible.
    • Nesting tons of folders in your source code is also not helpful.
  2. Since we need to have more items, here's another one.
    • I'm not sure if we'll bother styling more than two levels deep.
    • Two is already too much, three is guaranteed to be a bad idea.
    • If you nest four levels deep you belong in prison.
  3. Two items isn't really a list, three is good though.
    • Again please don't nest lists if you want people to actually read your content.
    • Nobody wants to look at this.
    • I'm upset that we even have to bother styling this.

The most annoying thing about lists in Markdown is that <li> elements aren't given a child <p> tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.

  • For example, here's another nested list.

    But this time with a second paragraph.

    • These list items won't have <p> tags
    • Because they are only one line each
  • But in this second top-level list item, they will.

    This is especially annoying because of the spacing on this paragraph.

    • As you can see here, because I've added a second line, this list item now has a <p> tag.

      This is the second line I'm talking about by the way.

    • Finally here's another list item so it's more like a list.

  • A closing list item, but with no nested list, because why not?

And finally a sentence to close off this section.

There are other elements we need to style

I almost forgot to mention links, like this link to the Tailwind CSS website. We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.

We even included table styles, check it out:

Wrestler Origin Finisher
Bret "The Hitman" Hart Calgary, AB Sharpshooter
Stone Cold Steve Austin Austin, TX Stone Cold Stunner
Randy Savage Sarasota, FL Elbow Drop
Vader Boulder, CO Vader Bomb
Razor Ramon Chuluota, FL Razor's Edge

We also need to make sure inline code looks good, like if I wanted to talk about <span> elements or tell you the good news about @tailwindcss/typography.

Sometimes I even use code in headings

Even though it's probably a bad idea, and historically I've had a hard time making it look good. This "wrap the code blocks in backticks" trick works pretty well though really.

Another thing I've done in the past is put a code tag inside of a link, like if I wanted to tell you about the tailwindcss/docs 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.

We haven't used an h4 yet

But now we have. Please don't use h5 or h6 in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a before pseudo-element to scream at you if you use an h5 or h6.

We don't style them at all out of the box because h4 elements are already so small that they are the same size as the body copy. What are we supposed to do with an h5, make it smaller than the body copy? No thanks.

We still need to think about stacked headings though.

Let's make sure we don't screw that up with h4 elements, either.

Phew, with any luck we have styled the headings above this text and they look pretty good.

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.

What I've written here is probably long enough, but adding this final sentence can't hurt.

Show code
<div class="prose-sm lg:prose xl:prose-lg max-w-none mx-auto">
  <p class="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>
  <pre><code class="language-html">&lt;article class="prose"&gt;
  &lt;h1&gt;Garlic bread with cheese: What the science tells us&lt;/h1&gt;
  &lt;p&gt;
    For years parents have espoused the health benefits of eating garlic bread with cheese to their
    children, with the food earning such an iconic status in our culture that kids will often dress
    up as warm, cheesy loaf for Halloween.
  &lt;/p&gt;
  &lt;p&gt;
    But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
    springing up around the country.
  &lt;/p&gt;
  &lt;!-- ... --&gt;
&lt;/article&gt;
</code></pre>
  <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&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1000&amp;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>
  <pre><code class="language-js">module.exports = {
  purge: [],
  theme: {
    extend: {},
  },
  variants: {},
  plugins: [],
}
</code></pre>
  <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>&lt;li&gt;</code> elements aren't given a child <code>&lt;p&gt;</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>&lt;p&gt;</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>&lt;p&gt;</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>&lt;span&gt;</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>