laraveltailwind-cssvitetailwind-css-4

Trouble Overriding Default Tailwind Colors in Laravel with Vite


I am currently following the path on Laracasts, and I am stuck trying to override the default Tailwind colors.

Here is my package.json:

{
  "private": true,
  "type": "module",
  "scripts": {
    "build": "vite build",
    "dev": "vite"
  },
  "devDependencies": {
    "autoprefixer": "^10.4.20",
    "axios": "^1.7.4",
    "concurrently": "^9.0.1",
    "laravel-vite-plugin": "^1.0",
    "postcss": "^8.5.1",
    "tailwindcss": "^4.0.1",
    "vite": "^6.0.11"
  },
  "dependencies": {
    "@tailwindcss/postcss": "^4.0.1",
    "@tailwindcss/vite": "^4.0.1"
  }
}

And here is my tailwind.config.js:

import defaultTheme from 'tailwindcss/defaultTheme';

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    './resources/**/*.blade.php',
    './resources/**/*.js',
  ],
  theme: {
    extend: {
      fontFamily: {
        sans: ['Figtree', ...defaultTheme.fontFamily.sans],
      },
      colors: {
        black: "#060606",
      },
    },
  },
  plugins: [],
};

Here is my app.css file:

@import "tailwindcss";
@source "../views";

And my PostCSS config file (postcss.config.js):

export default {
  plugins: {
    "@tailwindcss/postcss": {},
    autoprefixer: {},
  },
};

If anyone has an idea why it is not working as intended, I would really appreciate your help.


Solution

  • You're using a mixture of Tailwind v3 configuration but you have v4 installed. To fix: