Skip to main content
← Back to Table of Contents

Summary

Read-only table column for displaying ratings with the same visual language as RatingField. Supports fractional values with partial icon fill, custom icons, semantic colors, sizes, and optional numeric value display.
ClassBjanczak\FilamentFlexFields\Filament\Tables\Columns\RatingColumn
ContextFilament tables ($table->columns([...]))
State type`intfloatstringnull` (numeric values only)
ParentFilament\Tables\Columns\TextColumn
Shares rating display configuration with RatingField via matching fluent API. Column methods use a rating* prefix where they would conflict with TextColumn (ratingSize(), ratingColor(), ratingIcon()).

Basic usage

use Bjanczak\FilamentFlexFields\Filament\Tables\Columns\RatingColumn;
use Filament\Support\Icons\Heroicon;

RatingColumn::make('score')
    ->label('Rating');

RatingColumn::make('average_score')
    ->stars(10)
    ->ratingColor('success')
    ->ratingSize('lg');

RatingColumn::make('satisfaction')
    ->ratingIcon(Heroicon::Heart)
    ->ratingColor('danger')
    ->showValue(false);
Filament resolves $record->score as column state from the model attribute or relationship. Fractional values (e.g. 3.7) render with partial star fill.

Configuration API (RatingColumn-specific)

No column-only methods beyond inherited table APIs. All visual options come from the shared rating display API below.

Shared rating display API

These methods are identical to RatingField:
MethodDescription
stars(int|Closure $count)Number of rating items. Default: 5
ratingSize(string|ControlSize|Closure $size)Icon control size (sm, md, lg). Default: md (table scale: 16 / 18 / 20 px)
ratingColor(string|Closure|null $color)Semantic fill color (warning, primary, danger, success)
ratingIcon(string|BackedEnum|Htmlable|Closure|null $icon)Custom icon. Default: Heroicon::Star
showValue(bool|Closure $condition = true)Show numeric value (one decimal) beside icons. Default: true

Inherited TextColumn API

All Filament TextColumn methods apply: label(), sortable(), searchable(), toggleable(), alignStart() / alignCenter(), url(), tooltip(), etc. The column uses html() internally — do not call html(false) unless you override formatStateUsing().

Public helper methods

MethodReturnsDescription
formatRatingDisplay(mixed $state)stringRendered HTML for a state value
normalizeRatingFromState(mixed $state)?floatParsed numeric value clamped to 0…max, or null
getFillPercentageForValue(float|int|null $value, int $index)floatFill ratio 0.0–1.0 for icon at 1-based $index
getMax()intStar count
getRatingColor()stringSemantic color name
getRatingIcon()string|BackedEnum|HtmlableIcon reference
getRatingDisplaySize()stringIcon control size (sm, md, lg)
shouldShowValue()boolWhether numeric value is shown
getItemIndexes()list<int>1-based indexes for each star

CSS classes

ClassRole
fff-rating-columnCell wrapper (inline flex)
fff-ratingShared rating root (reused from RatingField)
fff-rating--{size}Size variant (sm, md, lg)
fff-rating--with-valueLayout when numeric value is shown
is-read-onlyNon-interactive display mode
fff-rating__itemsIcon row
fff-rating__icon-clipPartial fill clip for fractional values
fff-rating__valueNumeric value label

Performance

MechanismWhat it does
RatingColumnRenderCachePer-request cache of rendered rating HTML keyed by normalized value and column options. Identical ratings across rows reuse one Blade render.
Lazy CSSRatingColumn::setUp() registers rating-column in FlexFieldStylesheetQueue; queued-stylesheets render hooks emit flex-fields-rating-column.css once per request (no load-stylesheet in cell blades)