Tailwind's concept was a departure from previous approaches.
Classes for styling elements directly in HTML.
mx-auto (horizontal margin), p-2
(padding)
flex, grid, hidden
text-xl, text-black, font-mediummax-w-md (max width), size-12 (height
& width)
Prefix any class with a breakpoint size to apply that style only for screens larger than that.
one flex item
second flex item
Displays elements in a column on small screens and in a row above 768px screen width.
Like breakpoints, different element states and relationships can be targeted with the respective prefix too.
hover:… to apply styles on mouse overfocus-visible:… defines focus styles for keyboard usersfirst:… to style first siblinghas-checked:… applies if a checked checkbox is insideTailwind is fully customisable by specifying theme config (v3), setting theme variables (v4), or adding custom styles.
You can overwrite any and all aspects of Tailwind: colors, sizes, fonts, etc.
npm i tailwindcss @tailwindcss/vite@import "tailwindcss"; in root CSS fileBasic usage:
<div class="text-center bg-blue-500 text-white p-4 rounded-lg">
Hello, World!
</div>
Tailwind works nicely in with a Design System using Design Token.
The use of Tailwind avoids some of the major issues/challenges:
Docs and more at tailwindcss.com