Understanding Tailwind Config
The tailwind.config.js file is the heart of your Tailwind CSS setup. It allows you to customize every aspect of the framework, from colors and fonts to breakpoints and plugins.
Default Config
Tailwind comes with a sensible default configuration that works out of the box for most projects. Customizing it allows you to create a design system that matches your brand.
Customizing Colors
Colors are one of the most common customizations in Tailwind.
Primary and Secondary Colors
module.exports = {
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#10B981',
}
}
}
}Color Palettes
colors: {
blue: {
50: '#EFF6FF',
100: '#DBEAFE',
// ... more shades
900: '#1E3A8A',
}
}Font Configuration
Custom fonts help establish your brand identity.
Font Families
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Merriweather', 'serif'],
mono: ['Fira Code', 'monospace'],
}
}
}Font Sizes
fontSize: {
'xs': ['0.75rem', { lineHeight: '1rem' }],
'sm': ['0.875rem', { lineHeight: '1.25rem' }],
'base': ['1rem', { lineHeight: '1.5rem' }],
}Spacing and Layout
Customize spacing units to match your design system.
Spacing Scale
spacing: {
'1': '0.25rem',
'2': '0.5rem',
'3': '0.75rem',
'4': '1rem',
// ... more values
}Container Queries
container: {
center: true,
padding: '2rem',
screens: {
'2xl': '1400px',
}
}Breakpoints
Define custom breakpoints for responsive design.
Default Breakpoints
screens: {
'sm': '640px',
'md': '768px',
'lg': '1024px',
'xl': '1280px',
'2xl': '1536px',
}Custom Breakpoints
screens: {
'tablet': '640px',
'laptop': '1024px',
'desktop': '1280px',
}Border Radius
Customize border radius for consistent rounded corners.
borderRadius: {
'none': '0',
'sm': '0.125rem',
'DEFAULT': '0.25rem',
'md': '0.375rem',
'lg': '0.5rem',
'full': '9999px',
}Box Shadow
Define custom box shadows for depth.
boxShadow: {
'sm': '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
'DEFAULT': '0 1px 3px 0 rgba(0, 0, 0, 0.1)',
'md': '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
'lg': '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
'xl': '0 20px 25px -5px rgba(0, 0, 0, 0.1)',
}The Tailwind Config Generator tool simplifies the process of creating custom Tailwind CSS configurations. Whether you're setting up a new project, creating a design system, or customizing an existing setup, understanding Tailwind configuration is essential for efficient development. Start using the generator today to create your custom Tailwind configuration.