Tilly The Coder
Tilly The Coder
What’s New in Filament 5.12? Tables, Lazy State and Swift Highlighting
Tilly The Coder

What’s New in Filament 5.12? Tables, Lazy State and Swift Highlighting

Tilly The Coder
8 mins
This is the estimated time it takes to read the article.

Filament 5.12 is a useful upgrade if your admin panel spends most of its day showing tables, updating records and waiting for values to load. The release improves table rendering, adds policy checks to editable cells, and lets you defer the work behind individual cells or infolist entries. It also gives the code editor a way to load syntax highlighting for languages outside its built-in list, including Swift.

I tried these changes on a shipment queue with 25,000 records. The queue has enough rows to exercise pagination and filters, plus a review flag that users can toggle without opening the edit form. The same setup gives you a repeatable way to try the release in your own development panel. Start with the Filament 5.12.0 release notes for the full list.

Seed a queue you can actually use

Generate a Shipment model and migration, then a Filament resource for it. The examples below assume a panel is already installed and use only the fields needed for the demonstrations. Run the seeder on a development database. Its references are predictable so you can compare the same record before and after a code change.

php artisan make:model Shipment -m
php artisan make:filament-resource Shipment
php artisan make:seeder ShipmentSeeder

In the generated migration, use the following table definition. The unique reference lets the seeder skip rows that already exist. The compound index matches the example's status filter followed by reference order. A real application should choose indexes from the queries users actually run.

Schema::create('shipments', function (Blueprint $table): void {
    $table->id();
    $table->string('reference')->unique();
    $table->string('customer');
    $table->string('status');
    $table->unsignedSmallInteger('package_count');
    $table->date('booked_on');
    $table->boolean('is_flagged')->default(false);
    $table->boolean('is_locked')->default(false);
    $table->timestamps();
    $table->index(['status', 'reference']);
});

Add these casts to the Shipment model so the policy and calculated date can work with booleans and date objects.

protected function casts(): array
{
    return [
        'booked_on' => 'immutable_date',
        'is_flagged' => 'boolean',
        'is_locked' => 'boolean',
    ];
}

The seeder writes in batches of 75 to keep each insert small. Every seventh shipment is locked and every ninth starts flagged, so the table has enough variation to exercise both branches of the policy. The date is fixed to keep the dataset consistent across runs. Re-running the seeder keeps changes you made in the panel.

<?php

declare(strict_types=1);

namespace Database\Seeders;

use Carbon\CarbonImmutable;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

final class ShipmentSeeder extends Seeder
{
    public function run(): void
    {
        $customers = ['Alder & Ash', 'Bramble Supply', 'Cairn Studio'];
        $statuses = ['queued', 'in_transit', 'delivered', 'exception'];
        $date = CarbonImmutable::parse('2026-11-21');

        for ($start = 1; $start <= 25_000; $start += 75) {
            $rows = [];

            for ($i = $start; $i <= min($start + 74, 25_000); $i++) {
                $booked = $date->subDays($i % 180);

                $rows[] = [
                    'reference' => sprintf('SHP-%05d', $i),
                    'customer' => $customers[$i % count($customers)],
                    'status' => $statuses[intdiv($i, 3) % count($statuses)],
                    'package_count' => 1 + ($i * 7 % 24),
                    'booked_on' => $booked->toDateString(),
                    'is_flagged' => $i % 9 === 0,
                    'is_locked' => $i % 7 === 0,
                    'created_at' => $booked,
                    'updated_at' => $booked,
                ];
            }

            DB::table('shipments')->upsert($rows, ['reference'], ['reference']);
        }
    }
}
php artisan migrate
php artisan db:seed --class=ShipmentSeeder

Give the table a realistic workload

Open the resource with 25 rows per page, then repeat the same interactions with 100. Sort by reference, apply the status filter, go to the next page and toggle a review flag. Use the Network panel to compare the response size and server time for the same action. Browser rendering time is a separate measurement. A fast SQL query can still produce an expensive response if the table has many visible controls and repeated column markup.

Filament's table-rendering improvements are part of the release and require no flag. The rest of the example is configuration you can choose for each resource. Use the following methods on the generated table's configuration. Import Filament\Tables\Columns\TextColumn, Filament\Tables\Columns\ToggleColumn, Filament\Tables\Filters\SelectFilter and Illuminate\Database\Eloquent\Builder in the class.

return $table
    ->defaultSort('reference')
    ->paginated([25, 50, 100])
    ->columns([
        TextColumn::make('reference')->searchable()->sortable(),
        TextColumn::make('customer')->searchable(),
        TextColumn::make('status')->badge(),
        ToggleColumn::make('is_flagged')
            ->label('Review flag')
            ->authorize()
            ->partiallyRenderAfterStateUpdated(),
    ])
    ->filters([
        SelectFilter::make('status')->options([
            'queued' => 'Queued',
            'in_transit' => 'In transit',
            'delivered' => 'Delivered',
            'exception' => 'Exception',
        ]),
    ])
    ->selectableRecordsQuery(
        fn (Builder $query): Builder => $query->where('is_locked', false),
    );

The selection callback becomes relevant once the table has a bulk action. It allows Filament to count selectable records in SQL. Keep that predicate aligned with the authorization for the actual bulk action, and retain a policy check for every write. The database can quickly count unlocked rows, while a policy can still make a decision using the signed-in user and the record.

Authorize inline edits and update a single cell

Create app/Policies/ShipmentPolicy.php and add an update rule. The normal Laravel policy naming convention pairs Shipment with ShipmentPolicy. Add your application's tenant and role checks where users have different permissions. This lab assumes that access to the panel restricts who can view the queue.

public function update(User $user, Shipment $shipment): bool
{
    return ! $shipment->is_locked;
}

Calling authorize() on the toggle hooks it into the policy's update ability. Try SHP-00007 for a locked row and SHP-00008 for a row you can edit. The distinction matters when the same model can be edited through both a resource page and an inline control on a list.

The partial rendering option is a good fit when the flag affects only the toggle itself. If changing the flag also changes a badge, a summary or the filters that determine which rows appear, leave the full update in place so those parts of the interface refresh together. That is a useful comparison to make with the Network panel open, using the same record and filters for both requests.

Defer an expensive display value

The release can load individual column or infolist values after the surrounding interface appears. This is useful for values that users can wait briefly to see, such as a delivery estimate from a carrier. Keep cheap fields like the shipment reference in the initial response, so there is enough context to identify a row while the optional value loads.

For a local demo, add this column to the same table and import App\Models\Shipment. The date calculation itself is cheap. In a real application, put a slow lookup behind a read-only service and consider grouping or caching the lookups.

TextColumn::make('estimated_delivery')
    ->label('Estimated delivery')
    ->state(fn (Shipment $record): string => $record->booked_on->addDays(2)->toDateString())
    ->date('M j, Y')
    ->lazyLoadedState(),

A lazy value can load again after filtering or paging. Avoid writes or side effects inside the state callback. If several values come from one service call, group them with LazyLoadedStateGroup so they can share a request. Keep database sorting and filtering on real columns or query expressions. Filament's lazy column state documentation covers grouping and the lifecycle in more detail.

Add Swift highlighting to the code editor

The custom language API accepts a URL for a JavaScript module. The module exports a function that receives Filament's CodeMirror helpers and returns the language extension. This example bundles the legacy Swift mode into a small module served by the application. Syntax highlighting helps readers follow the example. Swift compilation and validation belong in Swift tooling.

npm install --save-dev @codemirror/legacy-modes esbuild
// resources/js/filament-swift-editor.js
import { swift } from '@codemirror/legacy-modes/mode/swift'

export default ({ language: { StreamLanguage } }) =>
    StreamLanguage.define(swift)
npx esbuild resources/js/filament-swift-editor.js --bundle --format=esm --outfile=public/js/filament-swift-editor.js
use Filament\Forms\Components\CodeEditor;
use Illuminate\Support\HtmlString;

CodeEditor::make('swift_source')
    ->language(asset('js/filament-swift-editor.js'))
    ->loadingPlaceholder(new HtmlString(
        '<div style="min-height: 10rem"></div>',
    ));

Put the field on a form with a swift_source state key, then paste a sample with a keyword, a string and a comment. Throttle the browser network and reload to see the placeholder while the editor initializes. If the placeholder stays on screen, check the module request and the browser console before changing the PHP. The CodeEditor documentation describes the module contract and how accessible loading indicators work.

What I would try first

Start with the busiest resource in your panel. Record a few common interactions using the version currently in your lockfile, upgrade in a branch, and repeat them with the same page size and data. Check your plugins and custom table columns as part of the comparison. Apply the inline policy where users change records directly, then decide which independent fields are worth deferring. The benefits are easiest to see when each change answers a specific problem in a screen people use every day.

The Filament 5.12 video walkthrough shows the shipment table, lazy placeholders and the editor in action. The video is available to paid members.