Tailwind CSS is an
open source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
CSS
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone t ...
framework. The main feature of this library is that, unlike other CSS frameworks like
Bootstrap, it does not provide a series of predefined classes for
elements
Element or elements may refer to:
Science
* Chemical element, a pure substance of one type of atom
* Heating element, a device that generates heat by electrical resistance
* Orbital elements, parameters required to identify a specific orbit of ...
such as buttons or tables. Instead, it creates a list of "utility" CSS classes that can be used to style each element by mixing and matching.
For example, in other traditional systems, there would be a class that would apply a yellow background color and bold text. To achieve this result in Tailwind, one would have to apply a set of classes created by the library: and .
As of 23rd January 2023, Tailwind CSS has over 64,400 stars on
GitHub
GitHub, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, co ...
.
Features
Due to the difference in basic concepts in relation to other traditional CSS frameworks such as Bootstrap, it is important to know the philosophy from which Tailwind was created, as well as its basic usage.
Utility Classes
The ''utility-first'' concept refers to the main differentiating feature of Tailwind. Instead of creating classes around components (button, panel, menu, textbox ...), classes are built around a specific style element (yellow color, bold font, very large text, center element...). Each of these classes is called utility classes.
There are many utility classes in TailwindCSS that enable to control a large number of
CSS
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone t ...
properties like colors, border, display type (''display''), font size and font, layout, shadow...
Variants
Tailwind offers the possibility to apply a utility class only in some situations through ''
media queries
Media queries is a feature of CSS 3 allowing content rendering to adapt to different conditions such as screen resolution (e.g. mobile and desktop screen size). It became a W3C recommended standard in June 2012,W3C – CSS specs > Media QueriesCod ...
'', which is called a variant. The main use of variants is to design a
responsive interface for various screen sizes. There are also variants for the different states an element can have, such as for when hovered, when keyboard selected or when in use, or when the browser or operating system has
dark mode
A light-on-dark color scheme —also called black mode, dark mode, dark theme, night mode, or lights-out (mode)— is a color scheme that uses light-colored text, icons, and graphical user interface elements on a dark background. It is often ...
enabled.
Variants have two parts: the condition to be met and the class that is applied if the condition is met. For example, the variant will apply the class if the screen size is greater than the value defined for .
Tailwind CSS is developed using
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
, runs via
Node.js, and installs with environment package managers like
npm or
yarn
Yarn is a long continuous length of interlocked fibres, used in sewing, crocheting, knitting, weaving, embroidery, ropemaking, and the production of textiles. Thread is a type of yarn intended for sewing by hand or machine. Modern manufac ...
.
Settings and Themes
It is possible to configure the utility classes and variants that Tailwind offers through a configuration file usually named . In the configuration one can set the values of the utility classes, such as the color-palette or the sizes between elements for margins.
Build All and Purge
The default mode of Tailwind is that the system generates all possible CSS combinations based on the project settings. Then, by means of another utility such as
PurgeCSS, all the files are traversed, and the classes that are not being used are removed from the resulting CSS file.
Due to the number of classes that can be generated by the number of variants and their combinations, this method has the drawbacks of long waiting times and large sizes of CSS files before being purged. This mode of operation is no longer available in version 3 of Tailwind CSS.
JIT
JIT mode (''Just-In-Time'') is an alternative way to generate the CSS that, instead of generating all possible classes and then removing all those that are not being used, parses the content of HTML files (or configured extensions or locations) and instantly generates only those classes that are needed and used.
Because all possible variables are no longer generated, the waiting time and size of the resulting CSS files is greatly reduced. This technical improvement has made it possible to introduce numerous new variants and utility classes, as well as the ability to create utility classes on the fly with arbitrary values not set in the configuration.
Starting with version 3 of Tailwind CSS, JIT mode has become the default.
Versions
Tailwind CSS uses
semantic versioning to identify its version compatibility.
Prominent uses
*
GitHub
GitHub, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, co ...
*
Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements current and ...
*
Netlify
*
NBA
The National Basketball Association (NBA) is a professional basketball league in North America. The league is composed of 30 teams (29 in the United States and 1 in Canada) and is one of the major professional sports leagues in the United ...
*
NASA
The National Aeronautics and Space Administration (NASA ) is an independent agency of the US federal government responsible for the civil space program, aeronautics research, and space research.
NASA was established in 1958, succeedi ...
*
Netflix
Netflix, Inc. is an American subscription video on-demand over-the-top streaming service and production company based in Los Gatos, California. Founded in 1997 by Reed Hastings and Marc Randolph in Scotts Valley, California, it offers a ...
*
The Verge
''The Verge'' is an American technology news website operated by Vox Media, publishing news, feature stories, guidebooks, product reviews, consumer electronics news, and podcasts.
The website launched on November 1, 2011, and uses Vox Media' ...
*
NBA
The National Basketball Association (NBA) is a professional basketball league in North America. The league is composed of 30 teams (29 in the United States and 1 in Canada) and is one of the major professional sports leagues in the United ...
See also
*
Bootstrap (framework)
References
{{Reflist, 2
External links
Official Tailwind Documentation
Tailwind Play real-time testing environment.
Web frameworks
Cascading Style Sheets