I have a Laravel Jetstream installation and use Tailwind CSS however the default colors do not work when using the tailwind components.
I only want to use the default colors and not custom yet.
tailwind.config.js
const defaultTheme = require('tailwindcss/defaultTheme');
module.exports = {
mode: 'jit',
purge: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
theme: {
extend: {
fontFamily: {
sans: ['Nunito', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
};
Jetstream came installed with Tailwind 2.2.2 which exhibits this issue. I have tried downgrading to 2.0.2 which was the latest version where this has been known to work for me but that also exhibits the issue
When using the same HTML code does work correctly when used in a Laravel Breeze using tailwind 2.0.2 installation.
example html
<div class="flex-shrink-0 flex items-center justify-center w-16 bg-pink-600 text-white text-sm font-medium rounded-l-md">
</div>
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"@tailwindcss/forms": "^0.3.1",
"@tailwindcss/typography": "^0.4.0",
"alpinejs": "^3.0.6",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"postcss-import": "^14.0.1",
"tailwindcss": "^2.2.2"
},
"dependencies": {
"daisyui": "^1.13.2"
}
}
in the example above the bg-pink-600 does not render.
You have to add the specific colors you need, available from the TailwindCSS palette, inside your tailwind.config.js
file like so:
tailwind.config.js
const defaultTheme = require('tailwindcss/defaultTheme');
const colors = require('tailwindcss/colors');
module.exports = {
mode: 'jit',
purge: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php'
],
theme: {
colors: {
transparent: 'transparent',
current: 'currentColor',
//amber: colors.amber,
black: colors.black,
blue: colors.blue,
cyan: colors.cyan,
emerald: colors.emerald,
fuchsia: colors.fuchsia,
gray: colors.trueGray,
blueGray: colors.blueGray,
coolGray: colors.coolGray,
//trueGray: colors.trueGray,
warmGray: colors.warmGray,
green: colors.green,
indigo: colors.indigo,
lime: colors.lime,
orange: colors.orange,
pink: colors.pink,
purple: colors.purple,
red: colors.red,
rose: colors.rose,
sky: colors.sky,//warn - As of Tailwind CSS v2.2, `lightBlue` has been renamed to `sky`.
teal: colors.teal,
violet: colors.violet,
yellow: colors.amber,
white: colors.white,
},
extend: {
fontFamily: {
sans: ['Nunito', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
};
Tip
You can actually check the available default colors inside the node_modules/tailwindcss/colors.js
file.
Once selected your colors and saved the file, now run again
npm run dev
Now refresh the caché of your web browser and reload the page (you'll probably have to sign in again into your Laravel application)