Introduction
The configuration file helps you customize Tailwind CSS easily. It controls colors, fonts, and other styles in one place.
Jump into concepts and practice - no test required
The configuration file helps you customize Tailwind CSS easily. It controls colors, fonts, and other styles in one place.
module.exports = {
content: [
'./src/**/*.{html,js}',
],
theme: {
extend: {
colors: {
customColor: '#123456',
},
},
},
plugins: [],
};The file is named tailwind.config.js.
Use module.exports to export your settings.
module.exports = {
content: ['./index.html'],
theme: {
extend: {},
},
plugins: [],
};brandBlue for your project.module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
colors: {
brandBlue: '#1DA1F2',
},
},
},
plugins: [],
};module.exports = {
content: ['./public/**/*.html'],
theme: {
extend: {
fontFamily: {
sans: ['Roboto', 'Arial', 'sans-serif'],
},
},
},
plugins: [],
};This HTML uses the custom color customColor and the default sans font from the Tailwind config.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Tailwind Config Example</title> <link href="./dist/output.css" rel="stylesheet"> </head> <body class="bg-customColor text-white font-sans p-6"> <h1 class="text-3xl font-bold">Hello Tailwind!</h1> <p>This page uses a custom color and font from the config file.</p> </body> </html>
Always restart your build tool after changing the config file to see updates.
Use the content array to tell Tailwind where your HTML or JS files are.
Keep your config organized by grouping similar settings inside extend.
The config file controls your Tailwind styles in one place.
You list your files in content so Tailwind knows where to look.
Use theme.extend to add or change colors, fonts, and more.
content array in the Tailwind configuration file?contentcontent array lists files where Tailwind looks for class names to generate styles.theme.extend, not content.tailwind.config.js?theme.extend.colors.tailwind.config.js snippet, what will be the background color class for the custom color?module.exports = {
theme: {
extend: {
colors: {
brand: '#1a202c'
}
}
}
}bg-[colorName] for backgrounds.brand, so background class is bg-brand.module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
primary: '#ff0000'
},
extend: {
fontFamily: {
sans: ['Arial', 'sans-serif']
}
}
}
}heading and a custom color accent without removing Tailwind's defaults. Which config structure correctly achieves this?theme.extend.module.exports = {
theme: {
extend: {
fontFamily: { heading: ['Georgia', 'serif'] },
colors: { accent: '#ff6600' }
}
}
} correctly puts both fontFamily and colors inside extend under theme.