Tailwind CSS
Purpose
It is used to create a set of utility class based on your theme configurations
Installation
Install the dependency
# Using npm
npm install tailwindcss autoprefixer postcss postcss-cliCreate a CSS file and inject tailwind's bases, components and utilities on it
@tailwind base;
@tailwind components;
@tailwind utilities;Generate the tailwind config, so that we can customize the style on it later
npx tailwindcss init --fullSet up post css configuration file
// postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
}
}Compile into a set of utility classes on
output.cssbased on your settings andinput.css
Utility-First Fundamentals
Using utility classes to build custom designs without writing CSS to prevent from the growth css file
The reusability of style is achieved based on separation of component instead of css class
Configuration
The configuration is mainly include content, theme & plugins
Content
The
contentsection of yourtailwind.config.jsfile is where you configure the paths to all of your HTML templates, JavaScript components, and any other source files that contain Tailwind class names.Tailwind uses a very simple approach to detecting class names in your content, and generate the your used class into
output.css
Theme
The
themesection of yourtailwind.config.jsfile is where you define your project’s design systemYou can extend or override the default theme
Plugin
Apply 3rd plugin which is a set of configuration to override or extend the theme
Directive
Directives are custom Tailwind-specific at-rules you can use in your CSS that offer special functionality for Tailwind CSS projects.
@tailwind
Base class stands for the a set of tailwind default element class
Component class stands for the custom class that applied tailwind utility class
Utilities class stands for the utility class that the
contentused
@layer
To customize the tailwind class in different levels
@apply
Use
@applyto inline any existing utility classes into your own custom CSS.
@config
To specify the source tailwind config file
Functions
Tailwind adds a few custom functions you can use in your CSS to access Tailwind configuration values.
Component Library
Tailwind UI
Last updated
Was this helpful?