Tailwind CSS Reference

Kip Landergren

(Updated: )

My cheat sheet for TailwindCSS.

Contents

Tips

Avoid “Styling at a Distance”

Write your Tailwind classes on the HTML (or component) that is being displayed. The further you are from the location of the applied style the harder it is to reason about how it is affected by intermediate logic.

Use the Prettier Plug-In

tailwindlabs/prettier-plugin-tailwindcss will sort your class names making development and code review much easier.

Avoid Dynamic Class Name Construction

A static class name string is unambiguous for Tailwind to parse and easier for users and tools to determine if there are conflicts.

If dynamic construction is necessary (e.g. due to combinatorial explosion: 6 boolean params results in 26 or 64 variants) consider:

Working with Tailwind CSS

Resources

References

Articles