Versions 4.16 / 5.11 and 4.17 / 5.12 of Filament are jam-packed with amazing updates, but I’ve picked out a few that stand out above the rest. Today, let’s talk through a few performance/UX updates that we’ve added to make your application feel snappy and polished, as well as one big update that we’ve been teasing for a while with regards to bringing JavaScript UI components right into your Filament applications!
#Using JavaScript components in your Filament panels
Rendering JavaScript components inside of a Filament panel has long been something that was possible, but it has largely been done without most of the niceties that you’d expect from working with Filament’s UI components as usual. That all changes with the v5.11 release (note that the v4 branch of Filament is not receiving the ability to add JS components to the panel). With this release, Filament now includes JavaScript renderers for custom form fields, schema components, and widgets, allowing you to drop in React, Vue, Svelte, and vanilla JS components and use them alongside your other normal Filament components.
This change opens up an entire world of possibilities by allowing you to use existing JavaScript components that may not yet have gotten a TALL-stack port to enhance your users’ experience. We know that many of our users are building back-end admin tooling with Filament for applications built with JavaScript framework front-ends (Inertia, Next.js, SvelteKit, etc.), so now you can bring your own application’s components directly into your admin tooling.
Bringing a JavaScript component into Filament is as simple as running a single command to generate the schema, just like you’d do with practically any other Filament component. For example, to generate a reusable React component, you can run php artisan make:filament-form-field LocationPicker --react --ts . From there, you can use the generated LocationPicker field in your schema just like any other Filament field. When you create JS Filament components in this manner, Filament owns the field wrapper and form state, so you can perform validation and save actions with the provided data as normal.
Want to make this all a little bit more concrete? I’ve created a Github repository that uses the React FullCalendar library’s “DayGrid” component inside of a normal Filament panel. In it, you can do everything you’d expect to do with a calendar component: render events, navigate between months, and select specific events on the calendar, all passing data back and forth between the JavaScript component and the wrapping PHP code.
Take a look for yourself here: https://github.com/alexandersix/filament-fullcalendar-daygrid
#Polishing your panel’s UX with placeholders
Following up on our JavaScript component addition, v4.17 and v5.12 expand on the existing UI placeholder system within Filament. This expansion comes in three parts:
- Adding additional points where UI placeholders can be enabled (previously this was limited to areas such as lazy-loaded tables and widgets)
- Adding the ability to customize UI placeholders with your own custom Blade views
- Adding UI placeholders to Filament JS components (only in v5.12)
In previous versions of Filament, you were somewhat limited in what you were able to do with our UI placeholders. You could enable them for lazy-loaded components like tables and widgets, but that was about the extent of the functionality that was available within Filament itself. Now, with these latest versions of Filament, we’ve opened up the placeholders system to many more places throughout the panel with a much higher degree of customization.
In v5.12, along with the aforementioned placeholder changes, you can now opt a table column or infolist entry into a “lazy loaded” state using the lazyLoadedState() method, which tells Filament to wait until the placeholder comes into view before resolving the value that is intended to fill that column/entry. This is particularly useful when you have one or more values that are off of the primary path and expensive to calculate, but are still important enough to the user to be included on the page when visible.
#Render less when editing a table
For a while now, Filament has rendered its tables directly in PHP rather than going through Blade components to reduce server-side rendering overhead without requiring you to change your table definition code. When we introduced this, the performance improvement was substantial.
Now we’re back again with another table-based performance improvement, though this time around the update is much more targeted and niche, but still incredibly helpful if you find yourself in a situation where this applies. Prior to v4.17 and v5.12, if you saved an editable table cell, the very action of saving a new value would refresh the entire Livewire component that owns the table. For small or simple tables, this isn’t a huge inconvenience, but when the table holds a large amount of data or data that is complex to compute, your application can start to feel sluggish.
In the latest versions of Filament, if nothing outside of the editable table cell needs to change, adding the partiallyRenderAfterStateUpdated() method to your cell definition will prevent the owning Livewire component from refreshing and only refresh the cell you’ve just edited, saving a massive amount of work. Even if one or more columns need to refresh depending on the edited data, you can use the partiallyRenderColumnsAfterStateUpdated() method to name the columns that should be re-rendered, while leaving all remaining columns and the parent Livewire component unchanged.
#Let us know what you think!
These are our favorite new features in v4.16/v5.11 and v4.17/v5.12, but there’s plenty more in the full release notes for v4.16.0, v4.17.0, v5.11.0, and v5.12.0.
Thanks to everyone who contributed to these releases! Let us know what you think of the new features and tell us how you’re going to use them in your applications!