Tricks

Customize Filament look with Tailwind CSS overrides

Jun 24, 2022
Simon Bühler
Admin panel, FAQ, Form builder, Table builder

When the default Filament look doesn't match your styling needs, its not recommended to publish & overwrite the views.

The best way is to create a custom theme and then override the Tailwind CSS classes of components e.g. .filament-button, input, select. Sometimes also siblings must be selected with CSS and customized.

  1. Applying Tailwind Classes

In /resources/css/filament.css you can apply Tailwind Classes like this:

@import '../../vendor/filament/filament/resources/css/app.css';
 
.filament-sidebar-item > a {
@apply bg-gradient-to-r from-rose-400 via-fuchsia-500 to-indigo-500 rounded-none hover:rotate-3
}
 
.filament-tables-row:nth-child(odd){
@apply bg-gray-50
}
  1. Customizing CSS

Another way is to write specific CSS in tailwind.config.js, a sample tailwind.config.js with some round corners removed looks like this:

const colors = require('tailwindcss/colors')
const plugin = require('tailwindcss/plugin');
const defaultTheme = require('tailwindcss/defaultTheme');
 
module.exports = {
content: [
'./resources/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
darkMode: 'class',
theme: {
extend: {
colors: {
danger: colors.rose,
primary: colors.yellow,
success: colors.green,
warning: colors.amber,
},
fontFamily: {
sans: ['DM Sans', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
plugin(function({ addComponents }) {
addComponents({
'.filament-button,.filament-tables-container': {
borderRadius: '0 !important'
},
'.filament-sidebar-item > a' :{
borderRadius: '0 !important'
},
'.filament-tables-pagination div' :{
borderRadius: '0 !important'
},
'.ring-2' : {
borderRadius: '0 !important'
},
'input,select' :{
borderRadius: '0 !important'
}
})
})
],
}
avatar

Hi Simon, thanks for the trick! How would you handle light and dark mode?