1. Getting Started
  2. Using webpack

Installation

Get started with Tailwind CSS

Tailwind CSS works by scanning all of your HTML files, JavaScript components, and any other templates for class names, generating the corresponding styles and then writing them to a static CSS file.

It's fast, flexible, and reliable — with zero-runtime.

Installing Tailwind CSS as a webpack loader

Installing Tailwind CSS as a webpack loader is the most seamless way to integrate it with webpack-based projects. It replaces the need for PostCSS in your webpack build pipeline.

01

Install Tailwind CSS

Install tailwindcss, @tailwindcss/webpack, and other webpack dependencies via npm.

Terminal
npm install tailwindcss @tailwindcss/webpack mini-css-extract-plugin css-loader
02

Configure webpack

Add @tailwindcss/webpack as a loader in your webpack.config.js file, along with css-loader and MiniCssExtractPlugin for extracting your CSS.

webpack.config.js
const MiniCssExtractPlugin = require('mini-css-extract-plugin')module.exports = {  plugins: [new MiniCssExtractPlugin()],  module: {    rules: [      {        test: /\\.css$/i,        use: [MiniCssExtractPlugin.loader, 'css-loader', '@tailwindcss/webpack'],      },    ],  },}
03

Import Tailwind CSS

Add an @import to your CSS file that imports Tailwind CSS.

CSS
@import "tailwindcss";
04

Start your build process

Run your build process with npx webpack serve or whatever command is configured in your package.json file.

Terminal
npx webpack serve
05

Start using Tailwind in your HTML

Make sure your compiled CSS is included in the <head>, then start using Tailwind's utility classes to style your content.

HTML
<!doctype html><html><head>  <meta charset="UTF-8">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <link href="/dist/main.css" rel="stylesheet"></head><body>  <h1 class="text-3xl font-bold underline">    Hello world!  </h1></body></html>
Are you stuck? Setting up Tailwind with webpack can be a bit different across different build tools. Check our framework guides to see if we have more specific instructions for your particular setup.
Copyright © 2026 Tailwind Labs Inc.·Trademark Policy