tailwind.config.js How to write ? #19154
Replies: 5 comments
-
| If you are using Tailwind v4, you shouldn't need a  | 
Beta Was this translation helpful? Give feedback.
-
| Related: | 
Beta Was this translation helpful? Give feedback.
        
          
            
              This comment was marked as spam.
            
          
            
        
      
    
            
              This comment was marked as spam.
            
          
            
        -
| Hello! In Tailwind CSS v4, the configuration approach has significantly changed. Here's what you need to know: For Tailwind v4 - CSS-Based Configuration /* main.css */
@import "tailwindcss";
@theme {
  /* Custom colors */
  --color-primary: #3b82f6;
  --color-secondary: #64748b;
  
  /* Custom fonts */
  --font-family-sans: 'Inter', 'system-ui';
  
  /* Custom spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  
  /* Breakpoints */
  --breakpoint-sm: 40rem;
  --breakpoint-md: 48rem;
  --breakpoint-lg: 64rem;
}
@layer base {
  /* Base styles */
  html {
    font-family: var(--font-family-sans);
  }
}
@layer components {
  /* Custom components */
  .btn-primary {
    @apply bg-primary text-white px-4 py-2 rounded;
  }
}
@layer utilities {
  /* Custom utilities */
  .text-shadow {
    text-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
  }
}If You Need a Config File (Legacy or Specific Cases) // tailwind.config.js (v3 style)
module.exports = {
  content: [
    "./src/**/*.{html,js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {
      colors: {
        primary: '#3b82f6',
        secondary: '#64748b',
      },
      fontFamily: {
        sans: ['Inter', 'system-ui'],
      },
    },
  },
  plugins: [],
}Key Changes in v4: 
 Migration from v3 to v4: 
 The official v4 documentation is available at: https://tailwindcss.com/docs/configuration | 
Beta Was this translation helpful? Give feedback.
-
| if youre using tailwind version 4, u dont need to tailwind config anymore bro... Tailwind version 4 is much easier than 3... u can simply define color,breakpoints and other things with your global.css/index.css (which one ur using) @theme { /* Custom fonts */ /* Custom spacing */ /* Breakpoints */ like this..and its really fun after u adapt it...easy peasy... | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I searched for a long time but couldn't find the official document.
Beta Was this translation helpful? Give feedback.
All reactions