Skip to main content
← Back to Table of Contents

Summary

A table column for displaying numeric ratings as a series of stars or custom icons. It supports fractional fills (e.g., 4.5 stars), custom icons, and color-coded states. Pair this with RatingField for a complete rating system.
ClassBjanczak\FilamentFlexFields\Filament\Tables\Columns\RatingColumn
State typefloat|int|null
Model cast'rating' => 'float'
Playgroundrating-column slug in Flex Fields playground
Default max5
Default iconheroicon-s-star

Basic usage

Standard 5-star rating

use Bjanczak\FilamentFlexFields\Filament\Tables\Columns\RatingColumn;

RatingColumn::make('average_rating')
    ->label('Score');

Custom icons and colors

RatingColumn::make('satisfaction')
    ->ratingIcon('heroicon-s-face-smile')
    ->ratingColor('success')
    ->stars(10);

State & formatting

Stored value

The column expects a numeric value (integer or float). Values exceeding the stars() count are capped at the maximum.
$record->rating; // 4.5

Fractional Fills

RatingColumn automatically calculates fractional fills for non-integer values. A rating of 3.7 will show three full stars and one star filled to 70%.

Displaying the numeric value

By default, the numeric value is shown next to the icons. You can hide it if needed:
RatingColumn::make('rating')
    ->showValue(false);

Configuration API

All methods accept Closure unless noted.
MethodTypeDefaultDescription
stars(int|Closure $count)Setup5Maximum number of icons to show
ratingColor(string|Closure $color)Setup'warning'Icon fill color
ratingIcon(string|Closure $icon)SetupstarFilament icon string
showValue(bool|Closure $cond)SetuptrueShow numeric value text
ratingSize(string|Closure $size)Setup'md'sm, md, lg

Real-world examples

Product Reviews Table

public static function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('title'),
            RatingColumn::make('rating')
                ->stars(5)
                ->ratingColor(fn ($state) => $state >= 4 ? 'success' : 'warning')
                ->sortable(),
        ]);
}

Playground

/admin/flex-fields-playground/rating-column See Playground for setup.
ComponentWhen to use instead
RatingFieldForm input for collecting ratings
NpsFieldSurvey-style NPS or Likert scales
ProgressBarLinear progress instead of icon rating

CSS classes (reference)

ClassRole
fff-rating-columnRoot wrapper
fff-rating-column__iconsContainer for all icons
fff-rating-column__icon-wrapperIndividual icon container
fff-rating-column__icon-bgBackground (empty) icon
fff-rating-column__icon-fillForeground (filled) icon
fff-rating-column__valueNumeric value text