What is Tailwind? - 图1

Tailwind CSS

A utility-first CSS framework for rapidly building custom user interfaces.

Tailwind is different from frameworks like Bootstrap, Foundation, or Bulma in that it’s not a UI kit.

It doesn’t have a default theme, and there are no built-in UI components.

On the flip side, it also has no opinion about how your site should look and doesn’t impose design decisions that you have to fight to undo.

If you’re looking for a framework that comes with a menu of predesigned widgets to build your site with, Tailwind might not be the right framework for you.

But if you want a huge head start implementing a custom design with its own identity, Tailwind might be just what you’re looking for.

Utility-first

Creating a framework for building custom UIs means you can’t provide abstractions at the usual level of buttons, forms, cards, navbars, etc.

Instead, Tailwind provides highly composable, low-level utility classes that make it easy to build complex user interfaces without encouraging any two sites to look the same.

Here’s an example of a responsive contact card component built with Tailwind without writing a single line of CSS:

What is Tailwind? - 图2

Component-friendly

While you can do a lot with just utility classes, sometimes a component class is the right decision.

Tailwind provides tools for extracting component classes from repeated utility patterns, making it easy to update multiple instances of a component from one place:

What is Tailwind? - 图3

Responsive to the core

Every Tailwind utility also comes in responsive flavors, making it extremely easy to build responsive interfaces without ever leaving your HTML.

Tailwind uses an intuitive {screen}: prefix that makes it easy to notice responsive classes in your markup while keeping the original class name recognizable and intact.

What is Tailwind? - 图4

all

What is Tailwind? - 图5

sm

What is Tailwind? - 图6

md

What is Tailwind? - 图7

lg

What is Tailwind? - 图8

xl

What is Tailwind? - 图9

Designed to be customized

If it makes sense to be customizable, Tailwind lets you customize it.

This includes colors, border sizes, font weights, spacing utilities, breakpoints, shadows, and tons more.

Tailwind is written in PostCSS and configured in JavaScript, which means you have the full power of a real programming language at your fingertips.

Tailwind is more than a CSS framework, it’s an engine for creating design systems.

  1. const colorPalette = {
  2. // ...
  3. 'grey-lighter': '#f3f7f9',
  4. // ...
  5. }
  6. module.exports = {
  7. // ...
  8. backgroundColors: colorPalette,
  9. borderColors: {
  10. default: colorPalette['grey-lighter'],
  11. ...colorPalette,
  12. },
  13. // ...
  14. }