Purging unused styles helps make your website load faster by removing CSS you don't use.
Purging unused styles in Tailwind
module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
extend: {},
},
plugins: [],
};The content array tells Tailwind where to look for class names to keep.
Only styles used in these files will be included in the final CSS.
index.html.module.exports = {
content: ['./index.html'],
theme: {},
plugins: [],
};src folder.module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {},
plugins: [],
};public and Vue/JS files in src.module.exports = {
content: ['./public/**/*.html', './src/**/*.{vue,js}'],
theme: {},
plugins: [],
};This simple HTML page uses Tailwind classes for background color, padding, text size, font weight, and colors.
When you build your CSS with purge enabled, only these used styles will be included in output.css.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Tailwind Purge Example</title> <link href="./dist/output.css" rel="stylesheet"> </head> <body class="bg-gray-100 p-6"> <h1 class="text-3xl font-bold text-blue-600">Hello, Tailwind!</h1> <p class="mt-4 text-gray-700">This page uses only a few Tailwind styles.</p> </body> </html>
Make sure the content paths in your Tailwind config match where your HTML or JS files are.
If you forget to include a file, styles used there might get removed.
During development, you can disable purging for faster builds, then enable it for production.
Purging removes unused Tailwind CSS styles to make your site faster.
Set the content option in your Tailwind config to tell it where to look for used classes.
Always check your final CSS size and test your site after purging to avoid missing styles.