FilamentF
Filament3y ago
ico

Filament v3 not detecting Tailwind classes

When i add a text input to have extra attributes like for example
TextInput::make('textInput')
  ->disabled(true)
  ->extraAttributes(['class'=>'bg-gray-500'])

It doesn't color the textinput
My
tailwind.config.js

const defaultTheme = require('tailwindcss/defaultTheme');
const colors = require('tailwindcss/colors')
const tailwindForms = require('@tailwindcss/forms');
const tailwindTypography = require('@tailwindcss/forms');

import preset from './vendor/filament/support/tailwind.config.preset'

module.exports = {

    presets: [preset],
    darkMode: 'class',
    content: [
        "./resources/**/*.blade.php",
        "./resources/**/*.js",
        "./resources/**/*.vue",
        './vendor/filament/**/*.blade.php',
        './app/Filament/**/*.php',
        './app/Http/Livewire/**/*.php',
        './resources/views/filament/**/*.blade.php',
    ],
    safelist: [
        'bg-orange-300',
        'bg-green-300',
    ],

    theme: {
        extend: {
            fontFamily: {
                sans: ['Nunito', ...defaultTheme.fontFamily.sans],
            },
            colors: {
                'add-item-btn-bg-bottom': '#78a4c6',
                'add-item-btn-bg-top': '#9bbdd9',
                'add-item-btn': '#639fd3',
                'add-item-delete-btn-bg-top': '#bcc8d3',
                'add-item-delete-btn-bg-bottom': '#a9c0d3',
                'sale-agreement-btn-bg': '#9abedd',
                danger: colors.rose,
                primary: colors.blue,
                success: colors.green,
                warning: colors.yellow,

            },
        },
    },

    plugins: [
        tailwindForms,
        tailwindTypography,
    ],
};

When i upgraded to Livewire v3 i chose to keep the current namespace
App\Htpp\Livewire
thats why that is in the
content
key
My filament form is actually in the same folder. I am building the form from a Livewire component. But the styling doesn't render.
What am i missing ?
Solution
I had this same issue. I resolved it but it's hacky. In my case it was that other built-in Filament classes had higher specificity, even though I had the ! for important. The way I handled it was by making a class, in my case called task-urgent. And I made a custom theme that defined this class but specifically targeted the class that was preventing me, like this:

.task-urgent .text-gray-950  {
    @apply !text-red-600;
}

This works but WILL break if Filament changes default colors. Not a great solution but CSS specificity is a pain.
Was this page helpful?