anselmocossa / filament-theme-grafite
Grafite: a calm, neutral theme for Filament v4 and v5 panels. Charcoal primary, hairlines instead of heavy shadows, Geist, an inset content panel, charts that read at a glance and themes people edit in the panel. Works with or without anselmocossa/filament-launchpad.
Package info
github.com/anselmocossa/filament-theme-grafite
pkg:composer/anselmocossa/filament-theme-grafite
Requires
- php: ^8.2
- filament/filament: ^4.0|^5.0
- illuminate/contracts: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- spatie/laravel-permission: ^6.0|^7.0|^8.0
Suggests
- ext-gd: for themes(): to keep a lighter copy of a background image and check the text over it
- anselmocossa/filament-launchpad: ^1.18, to show Launchpad cards as their tiles on the search results page
Provides
None
Conflicts
None
Replaces
None
README
A calm, neutral theme for Filament v4 and v5 panels.
- Neutrals do most of the screen. Colour only marks the primary action, state and selection.
- 1px hairlines instead of heavy shadows. One font: Geist, with tabular numbers in tables and stats.
- The page sits in an inset panel over a grey frame, with a sidebar or with top navigation.
- Dark mode has its own values. It is not an inversion of the light one.
- Charts that read at a glance: every
ChartWidgetof the panel gets the palette, the tooltip, the series totals and a table view, with no change to the widgets. - Plain CSS and one small script. No Vite or Tailwind build step in your app.
- Knows
anselmocossa/filament-launchpad: the tiles follow the theme, and so do the spaces, in the topbar (topbarNavigation()), in the sub-menu at the top of the page panel (subNavigation()) or in the tab bar of phones (bottomNavigation()).
Screenshots
A dashboard: stats with the change as a pill, charts with the headline figure, the series totals and the period
in the header.
Dark mode has its own values: bars turn horizontal when the labels don't fit, the average is a labelled line,
the part of a bar over the budget is hatched.
The tooltip lists the series and the change against the target; the cards in a row share their height and the
sentence under each chart lines up.
A doughnut with the total in the middle and its slices as a list; a long top 10 as a ranked list.
Tables with a 42px header row, quiet row actions and status badges as neutral pills with a coloured dot.
Fields with a hairline, tabs on the left, form actions on the right.
searchResultsPage(): every result of the global search, grouped by resource, with tabs and pages.
With the Launchpad: the spaces beside the logo and the KPI tiles in the chart colour.
On a phone: one-row topbar, charts that fit the width, the Launchpad tab bar at the bottom.
Installation
composer require anselmocossa/filament-theme-grafite php artisan filament:assets
Register the plugin in the panel provider:
use Filament\Grafite\GrafitePlugin; $panel->plugin(GrafitePlugin::make());
Options
GrafitePlugin::make() ->primaryColor('#0170B9') // default #18181B (charcoal) ->font(false) // keep the font the panel already sets ->searchShortcut(false) // no Cmd+K / Ctrl+K on the global search ->roundedPanel(false) // the page panel with straight corners ->insetPanel(false) // the page panel fills the window, no grey margin around it ->brandDivider() // a short separator between the logo and the top navigation ->breadcrumbSeparator('slash') // "/" between the breadcrumbs of every page (default 'chevron') ->centeredSearch() // the global search in the middle of the topbar, wider ->searchResultsPage() // Enter in the global search opens a page with every result ->charts(extras: true) // the charts with a sentence and the peak marked (see Charts) ->themes(); // Settings > Themes and Appearance in the user menu (see Themes)
- A near-black primary is treated as neutral: buttons are charcoal in light mode and near-white in dark mode. Any other colour is kept in light mode and lightened for dark mode.
- Grafite sets the panel's
primaryandgraycolours and the font when the panel boots, so it wins over->colors()and->font()in the provider, whatever the order. - The page sits in a panel with rounded corners over the grey frame.
roundedPanel(false)keeps the frame and the hairline and squares the corners.insetPanel(false)drops the grey margin at the sides and the bottom: the panel fills the window under the grey topbar, with straight corners and no line around it, and the page sits 16px from the edge, in line with the topbar. - The panel has the same hairline all round, the top included, and its top edge stays under the topbar when the page scrolls: the rounded corners and the hairline keep their place and the content slides in under them.
brandDivider()draws the separator of the design between the logo and the top navigation: 20px tall, 12px after the logo and 10px before the first item. It is off by default, and a topbar without navigation never shows it.breadcrumbSeparator()picks the separator between the breadcrumbs of every page of the panel:'chevron'(Filament's own, the default),'slash', or any icon (Heroicon::MinusSmall, a Blade icon name). It goes through Filament's icon alias, so the theme editor, which draws its own breadcrumbs, shows the same one.centeredSearch()puts the global search in the middle of the topbar, half the window wide up to 560px, and opens the suggestions as wide as the field. It applies from 768px up and only when the topbar has no navigation, where the middle is free.- The global search opens with Cmd+K (macOS) or Ctrl+K and shows the key inside the field. A panel that sets
its own
->globalSearchKeyBindings()keeps them. searchResultsPage()adds a page at/search?q=.... Enter in the global search opens it, and the suggestions end with a link to it ("See all 18 results for ..."). The suggestions stay short, without a scroll: the first 3 groups, 3 results each; the link counts them all. The page lists every result grouped by resource, in the order of the global search, with a tab per resource (&group=postsin the address), a "See all in ..." link to the resource list with the same words in its table search, and an empty state. The words of the search are marked in bold and underlined, on the page and in the suggestions. Nothing scrolls without end: "All" pages the resources 3 at a time, each with its first 5 results (6 cards) and a "Show 45 more" that opens its tab, and a tab pages its results 10 at a time (12 cards). The bar keeps four tabs, "All" included; the other resources wait under "More", and the open one always has its tab. Each resource holds up to its global search limit (50 by default). Grafite wraps the panel's own search provider, so a custom provider keeps working: its categories show as they come, without icons or "See all" links. With Launchpad 1.18 or later on the panel, Launchpad cards show as their real tiles, with the places where each card sits under it. Off by default.
Small screens
- Below 768px the topbar keeps one row down to 320px: the global search shrinks and drops the shortcut key, and
the separator of
brandDivider()hides once the top navigation folds into its menu. - Toggle buttons, grouped or inline, are one box with the choices joined by the hairline. Below 768px they stack into one list, a choice per line, full width.
- Below 640px the tabs go on to a second row, the table search shrinks beside its buttons and the rich editor tools wrap one by one, so nothing runs past the edge.
Charts
Every ChartWidget of the panel takes the Grafite look by itself; there is nothing to change in the widgets:
- Eight colours in a fixed order, chosen so that neighbours stay apart for colour blindness, with their own steps in dark mode. A dashed dataset is a reference (a target, last year) and takes the grey. A ninth series is grey rather than a made-up colour.
- Lines with a soft fill that fades to the axis, bars with rounded ends and a 2px gap, compact numbers on the value axis (12K, 1.5M) and the year left out of the dates when they share it. Bars turn horizontal when the labels don't fit under them.
- A tooltip that lists the series with their values and, against a reference, the change: "+5.5% vs Target".
- The series as chips with their total (the last value for a running total, the average for a percentage); clicking one hides it.
- A filter with 2 to 4 options becomes a segmented control in the card header, beside a chart/table switch.
- An empty state when every value is zero, instead of a flat line on the floor.
- Doughnut and pie with the total in the middle and the slices as a list with their shares.
- The keyboard moves through the points with the arrow keys, and a screen reader hears the values.
- The cards in a row share their height, and what sits at the bottom of each card lines up.
The panel options:
GrafitePlugin::make() ->charts(palette: false) // keep each widget's own colours ->charts(animate: false) // no drawing-in ->charts(table: false) // no chart/table switch ->charts(extras: true) // a sentence under every chart and its peak marked ->charts(false); // Filament's charts, untouched
What the data alone cannot tell, a widget says in its options, under plugins.grafite:
protected function getOptions(): array { return [ 'plugins' => [ 'grafite' => [ 'headline' => 'sum', // a figure over the chart: sum, avg, last, max or min 'unit' => 'orders', // the word after the figure 'compare' => true, // the change of the figure against the reference dataset 'better' => 'down', // which way is good, for the colour of the change (up by default) 'mark' => 'max', // a dot and the value on max, min or last; ['top' => 2] for the two highest 'lines' => ['avg'], // lines across: avg, median, or ['value' => 100, 'label' => 'Budget'] 'emphasis' => 'max', // one bar in colour (max, min or last), the others lighter 'values' => true, // the value at the end of each bar 'scale' => 'sequential', // one colour, light to dark by value, for bars that are one measure 'as' => 'list', // a ranked list instead of a bar chart 'progress' => 1, // a meter of the first dataset against dataset 1 (a budget) 'prefix' => '$', // around the numbers ('%' is added when the label has one) 'suffix' => ' h', 'insight' => true, // a sentence under the chart: the peak, the share, the days over the line ], ], ]; }
Chart.js reads plugins as its own option, so these sit next to the usual scales and plugins.legend, which
keep working. The colours are CSS variables (--g-chart-1 to --g-chart-8, --g-chart-ref, light and dark):
override them in the panel theme to use other colours.
With the Launchpad, the KPI sparklines take the first chart colour too, over the chart grid line
(--lp-sparkline, --lp-sparkline-base); charts(palette: false) leaves each tile its own colour.
Stats
A stat reads as label, figure, then the change. Put the unit in <small> and the change in <strong>:
use Illuminate\Support\HtmlString; Stat::make('Revenue', new HtmlString('86,420 <small>MT</small>')) ->description(new HtmlString('<strong>+12.4%</strong> vs yesterday')) ->descriptionColor('success') ->chart($lastTwelveMonths) // optional: a line along the bottom edge ->chartColor('success'); // same colour as the pill
<strong>becomes a soft pill in the description colour; the rest of the description stays grey.- Without
chart()the card is compact. With it, the line runs along the bottom edge in the chart colour (grey when none is set) over a faint fill.
Themes
themes() lets the people who run the panel change its colours without code: a list of themes under
Settings > Themes, an editor with a live preview, and a theme for each panel. Each person may then switch the
theme for themselves under Theme, in the user menu, next to Filament's own light and dark switch.
GrafitePlugin::make()->themes( label: 'Front desk', // the panel's name in Settings > Themes (its id by default) editor: true, // false: the menu item only; the themes are edited in another panel appearance: true, // false: nothing in the user menu, everyone keeps the panel's theme appearanceMode: false, // true: Appearance, the theme and the mode in one dialog (see below) navigationGroup: 'Settings', // the group of Settings > Themes navigationSort: 90, disk: 'public', // where the background images and the logos go classic: true, // false: Clássico, the square built-in theme, is not offered );
Run the migrations it brings (php artisan migrate): three tables, grafite_themes, grafite_panel_themes
and grafite_user_themes, and the two built-in themes, Grafite and Clássico.
- The list shows every theme with its colours, the panels that open with it, its state (published or draft) and how many people picked it, and above it the theme each panel opens with and whether its people may choose their own. A panel change applies at once.
- The built-in Grafite keeps the colours of
primaryColor()and cannot be changed or deleted; duplicate it to start a theme of your own. - The built-in Clássico is Grafite with square corners: the same colours, no curve on cards, tables,
buttons, fields, lists, menus, dialogs, tabs, badges, counters, the wizard steps, the page panel and the active
item of the bar. The avatar, the toggle, the radio and the status dots stay round. It is offered in Theme (and
Appearance) next to Grafite;
themes(classic: false)leaves it out of the user menu. - The editor has the name, "Available in Appearance", the panels that open with the theme, and per mode (light and dark) the primary colour, the secondary colour (links, the chosen tab, info badges and the second chart colour), the bar (the top bar and the frame around the page are always one colour; a sidebar sits on it and takes the bar's letters), the active item (the place you are in, on the bar and in the sidebar: Automatic follows the bar, or a colour of its own with letters that pick light or dark by themselves), the page background and the cards (raised or the same as the page). Corners (Rounded or Square) holds for the whole panel in both modes, so any theme can be square like Clássico. "Generate" picks dark colours from the light ones. A background image (JPG, PNG or WebP up to 2 MB) goes behind the page with a veil of the page colour per mode, on the home page only or on every page, and on the sign-in screen if asked; the panel keeps a lighter copy and drops what the camera wrote into the file. Two logos, for light and dark bars, replace the panel's: the bar shows the one that reads on it.
- Checks measure every colour as you type (WCAG, 4.5:1 for text): the letters on the primary buttons, links on the page and on cards, the bar's letters, the letters of the active item (and a warning when it can hardly be told from the bar), the text on the page and the text over the image through the veil. Publish stays off while one fails, in either mode, and the server checks again before publishing.
- Draft and publish: a new theme is a draft until Publish. Changes to a published theme are kept aside (Save draft) and people keep the published colours until Publish. People see a new version when they reload.
- Theme, in the user menu, opens the themes offered in Appearance plus the panel's own, and the mode (Light, Dark, System) next to them. The theme is saved in the account; the mode in the browser, the same one Filament's light and dark switch uses, which stays as it is. It shows only when the panel lets people choose and there is more than one theme. A click shows the theme or the mode on the page at once (colours, background image, logos); Cancel, the cross or Esc put the page back, and Save keeps it. With few themes the cards take the whole width; on a phone it opens from the bottom.
- Appearance, with
appearanceMode: true, puts the mode (Light, Dark, System) in the same dialog as the theme and takes the place of Filament's switch. The mode is saved in the account, so it follows the person to any browser, and the item shows even where the panel does not let people pick a theme. - Permissions follow Shield's names:
ViewAny:Theme,Create:Theme,Update:Theme,Delete:Theme. Without spatie/laravel-permission, or before Shield generates them, everyone who reaches the panel may use Settings > Themes; once they exist, only the roles given them (andsuper_admin). - Square corners in your own CSS: the stylesheet multiplies its fixed radii by
--g-k(1, or 0 for a square theme), soborder-radius: calc(8px * var(--g-k, 1))follows the theme. Filament's own--radius-*go to 0 as well, and so do the Launchpad tiles (--lp-tile-radius, from filament-launchpad 1.22.0). - The built-in Grafite writes exactly the stylesheet of 1.0.0, so a panel that never publishes a theme looks the same. The background image and the check over it need PHP's GD; without it the image is kept as it came and the editor's check in the browser stands alone.
Updating
The stylesheet and the chart script are published to public/css/anselmocossa/filament-theme-grafite/ and
public/js/anselmocossa/filament-theme-grafite/. Run
php artisan filament:assets after every update of the package (Filament's filament:upgrade script does it
for you if it is in your post-autoload-dump), and php artisan migrate when a version brings a migration
(1.2.0 adds the corners of each theme and Clássico).
Testing
composer test
The feature tests (Settings > Themes, the editor, Appearance) run on Orchestra Testbench with an in-memory SQLite database.
License
MIT. See LICENSE.md.
