Skip to main content
← Back to Table of Contents

Summary

Read-only table column for displaying blade-icons values stored by IconPickerField. Renders the SVG icon with optional human label, technical name, semantic color, and size tokens shared with the flex-field design system.
ClassBjanczak\FilamentFlexFields\Filament\Tables\Columns\IconColumn
ContextFilament tables ($table->columns([...]))
State type`stringnull— full icon name (e.g.heroicon-o-star`)
ParentFilament\Tables\Columns\TextColumn
Import alias: Filament ships its own Filament\Tables\Columns\IconColumn. When you need both, alias this class:
use Bjanczak\FilamentFlexFields\Filament\Tables\Columns\IconColumn as FlexIconColumn;

Basic usage

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

IconColumn::make('menu_icon')
    ->label('Icon');

IconColumn::make('status_icon')
    ->iconColor('success')
    ->iconSize('lg')
    ->showLabel();

IconColumn::make('debug_icon')
    ->iconSize('sm')
    ->showLabel()
    ->showName()
    ->tooltip(fn (?string $state): ?string => $state);
Filament resolves $record->menu_icon as column state from the model attribute. Values must match the same blade-icons strings saved by IconPickerField.

Usage on the frontend

IconColumn is for Filament admin tables only. The same database value powers your public site — render it with blade-icons:
@if (filled($menuItem->icon))
    <x-icon :name="$menuItem->icon" class="h-5 w-5" />
@endif
See IconPickerField — Usage on the frontend for Filament generate_icon_html() and model examples.

Configuration API (IconColumn-specific)

All methods accept Closure for dynamic configuration.
MethodDescriptionDefault
iconSize(string|ControlSize|Closure $size)Icon control size (sm, md, lg)md
iconColor(string|array|Closure|null $color)Semantic Filament color on the icon shellnull
showLabel(bool|Closure $condition = true)Show human-readable label beside the iconfalse
showName(bool|Closure $condition = true)Show full technical icon name (monospace)false
labelUsing(?Closure $callback)Custom label resolver — receives ['icon' => string]catalog label

iconSize(string|ControlSize|Closure $size)

use Bjanczak\FilamentFlexFields\Enums\ControlSize;

IconColumn::make('menu_icon')->iconSize('sm');
IconColumn::make('menu_icon')->iconSize(ControlSize::Lg);
Maps to Filament IconSize: sm → Small, md → Medium, lg → Large.

iconColor(string|array|Closure|null $color)

IconColumn::make('status_icon')->iconColor('warning');
IconColumn::make('status_icon')->iconColor('primary');
Adds fi-color-{color} on the column shell when set.

showLabel() / showName()

IconColumn::make('menu_icon')
    ->showLabel(); // "Check Circle" from heroicon-o-check-circle

IconColumn::make('menu_icon')
    ->showLabel()
    ->showName(); // label + heroicon-o-check-circle
Default labels use IconCatalogResolver::formatIconLabel() — the same headline logic as IconPickerField search results.

labelUsing(?Closure $callback)

IconColumn::make('menu_icon')
    ->showLabel()
    ->labelUsing(fn (array $arguments): string => match ($arguments['icon']) {
        'heroicon-o-home' => 'Homepage',
        default => 'Menu item',
    });

Inherited TextColumn API

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

Public helper methods

MethodReturnsDescription
formatIconDisplay(mixed $state)stringRendered HTML for a state value
normalizeIconFromState(mixed $state)?stringTrimmed icon name or null
renderIconHtml(string $icon)stringCached SVG HTML via IconSvgCache
resolveIconLabel(string $icon)stringHuman label from catalog or labelUsing()
getIconDisplaySize()stringResolved size (sm, md, lg)
getIconDisplayColor()string|array|nullResolved semantic color
shouldShowLabel() / shouldShowName()boolText display flags

Recipe: navigation table

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

public function table(Table $table): Table
{
    return $table
        ->columns([
            IconColumn::make('icon')
                ->label('Icon')
                ->iconSize('md'),
            TextColumn::make('label'),
            TextColumn::make('route'),
        ]);
}

Recipe: status column with color + label

IconColumn::make('status_icon')
    ->label('Status')
    ->iconColor(fn (string $state): string => match ($state) {
        'heroicon-o-check-circle' => 'success',
        'heroicon-o-exclamation-triangle' => 'warning',
        'heroicon-o-x-circle' => 'danger',
        default => 'gray',
    })
    ->showLabel()
    ->sortable();

Recipe: pair with IconPickerField on a Resource

// Form
IconPickerField::make('menu_icon')
    ->sets(['heroicons'])
    ->required();

// Table
IconColumn::make('menu_icon')
    ->showLabel()
    ->iconSize('sm');

CSS classes

ClassRole
fff-icon-columnColumn cell root
fff-icon-column--sm / --md / --lgSize modifiers
fff-icon-column--with-labelIcon + text layout
fff-icon-column__iconSVG wrapper
fff-icon-column__textLabel/name stack
fff-icon-column__labelHuman-readable label
fff-icon-column__nameTechnical icon name

Performance

MechanismDetail
IconColumnRenderCachePer-request cache of rendered HTML keyed by icon + column options
IconSvgCacheServer-side SVG HTML cache (shared with IconPickerField)
Lazy CSSIconColumn::setUp() registers icon-column in FlexFieldStylesheetQueue; queued-stylesheets (render hooks at STYLES_AFTER / BODY_END) emits flex-fields-icon-column.css once per request
DedupmarkStylesheetsEmitted() + asset injector prevent duplicate <link> tags on repeat hook passes and SPA navigation
Playground slug bundle/flex-fields-playground/icon-column loads playground-icon-column.css; suppressForPlaygroundBundle() skips redundant lazy injection

Playground

  • Main playground section: IconColumn (mock table after RatingColumn)
  • Dedicated page: /admin/flex-fields-playground/icon-column (when playground is enabled)

See also