Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here
Tutorial Free

Filament: Create Custom Table Column - Progress Bar Example

October 24, 2023
2 min read

Filament has many pre-defined Table columns, but what if you want to create your own custom one? This tutorial will show you how.

Let's say we want to show a nice progress bar in a table. So, we have a Model named Level with a progress field with values ranging from 0 to 100 and transform it into this:

Progress Column


Create a custom ProgressColumn component.

php artisan make:table-column ProgressColumn

Update Blade view for this component.

resources/views/tables/columns/progress-column.blade.php

<div class="progress-bar">
<div class="progress-bar-value" style="width: {{ $getState() }}%;">
{{ $getState() }}%
</div>
</div>

For CSS to work in custom components, create a theme for your project. And follow a few steps.

php artisan make:filament-theme

More information on themes can be found in the official Filament documentation.

Then, add your CSS to the file created by the command.

resources/css/filament/admin/theme.css

@import '/vendor/filament/filament/resources/css/theme.css';
 
@config 'tailwind.config.js';
 
.progress-bar {
@apply h-4 w-full bg-gray-100 dark:bg-gray-800 rounded-full shadow-inner overflow-hidden
}
 
.progress-bar-value {
@apply flex h-full items-center justify-center bg-primary-600 dark:bg-primary-500 rounded-r-full shadow-inner text-xs font-bold text-white;
}

Now you can use ProgressColumn in all your tables.

app/Filament/Resources/LevelResource.php

use App\Tables\Columns\ProgressColumn;
 
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
ProgressColumn::make('progress'),
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

Compile everything by running npm run build and see the result.

Progress Column


If you want more Filament examples, you can find more real-life projects on our FilamentExamples.com.

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Comments & Discussion

MN
Mehmet Nurullah Sağlam ✓ Link copied!

i think you forgot to add the theme to AdminPanelProvider but hey, great tutorial, thanks!

M
Modestas ✓ Link copied!

This tutorial was not really about the creation of Filament theme, rather a custom component. Also, the documentation should have it, which was referenced :)

ND
Nils Domin ✓ Link copied!

Thanks! :-)

MM
Marc Michels ✓ Link copied!

This is just what I was looking for - BUT - is there a way to query the DB how much of a certain record has been filled in. I have tables with more than 50 columns which are mostly nullable but want my users to fill in as much as possible. This way I create a sort of competition element on the site as anyone can see the eachothers tables. There are some (hacky) ways to do it on the DB directly but is there not a way to 'eloquently' get these numbers on create and edit actions and then store the numbers in their own column?

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.