Type to search columns, filters, options, and extensions.

to navigate · Enter to open · Esc to close

Documentation

Icon Column

Render a Lucide icon instead of text, driven by a static value or a callable, with an optional boolean mode, sizes, and tooltips

The IconColumn renders a Lucide icon instead of raw text. The icon and its color are set with icon() and color(), each accepting a static value (rendered client-side) or a callable that receives the cell state and is resolved server-side per row.

Icon names may be passed as plain kebab-case strings ('circle-check') or as Icon enum cases (Icon::CircleCheck) — both serialize to the same value.

Basic Usage

Set a single static icon for every cell:

use Pentiminax\UX\DataTables\Column\IconColumn;
use Pentiminax\UX\DataTables\Enum\Icon;

IconColumn::new('status', 'Status')
    ->icon(Icon::CircleCheck);

Dynamic Icon

Pass a callable to derive the icon from the cell value. The callable receives the (scalar) cell state:

IconColumn::new('status', 'Status')
    ->icon(fn (string $state): Icon => match ($state) {
        'draft'     => Icon::PencilLine,
        'reviewing' => Icon::Clock,
        'published' => Icon::CircleCheck,
        default     => Icon::Circle,
    });

The callable runs server-side, once per row. It may return a string or an Icon.

Colors

color() accepts a semantic variant (success, warning, danger, info, primary, secondary, light, dark) as a static string or a callable. Each adapter maps the variant to its own classes — text-success on Bootstrap, text-green-600 on Tailwind.

IconColumn::new('status', 'Status')
    ->icon(fn (string $state): Icon => match ($state) {
        'draft'     => Icon::PencilLine,
        'published' => Icon::CircleCheck,
        default     => Icon::Circle,
    })
    ->color(fn (string $state): string => match ($state) {
        'draft'     => 'warning',
        'published' => 'success',
        default     => 'secondary',
    });

Boolean Mode

boolean() switches to a true/false rendering driven by trueIcon/falseIcon and trueColor/falseColor:

IconColumn::new('enabled', 'Enabled')
    ->boolean()
    ->trueIcon(Icon::CircleCheck)
    ->falseIcon(Icon::CircleX)
    ->trueColor('success')
    ->falseColor('danger');

Sizes

size() accepts xs | sm | md | lg | xl (default md), as a string or an IconSize enum case:

use Pentiminax\UX\DataTables\Enum\IconSize;

IconColumn::new('status', 'Status')
    ->icon(Icon::CircleCheck)
    ->size(IconSize::Large);

Sizes map to pixel dimensions: xs=12, sm=16, md=20, lg=24, xl=32.

Tooltips

Add a title attribute per value:

IconColumn::new('status', 'Status')
    ->icon(Icon::CircleCheck)
    ->tooltips(['active' => 'Account is active']);

API Reference

MethodDescription
IconColumn::new(string $name, string $title = '')Creates a new IconColumn (type: html).
icon(string|Icon|callable $icon)Icon name (string/Icon) rendered client-side, or a fn ($state) resolved server-side per row.
color(string|callable $color)Semantic variant (string) rendered client-side, or a fn ($state) resolved server-side per row.
size(string|IconSize $size)Icon size: xs | sm | md | lg | xl (default md).
tooltips(array $tooltips)Map of cell value => title attribute.
boolean(bool $boolean = true)Switch to true/false rendering.
trueIcon(string|Icon $icon) / falseIcon(string|Icon $icon)Icons used in boolean mode.
trueColor(string $color) / falseColor(string $color)Variants used in boolean mode.

Complete Example

use Pentiminax\UX\DataTables\Attribute\AsDataTable;
use Pentiminax\UX\DataTables\Column\IconColumn;
use Pentiminax\UX\DataTables\Column\TextColumn;
use Pentiminax\UX\DataTables\Enum\Icon;
use Pentiminax\UX\DataTables\Enum\IconSize;
use Pentiminax\UX\DataTables\Model\AbstractDataTable;

#[AsDataTable(User::class)]
final class UsersDataTable extends AbstractDataTable
{
    public function configureColumns(): iterable
    {
        yield TextColumn::new('name', 'Name');
        yield IconColumn::new('status', 'Status')
            ->icon(fn (string $state): Icon => match ($state) {
                'active'   => Icon::CircleCheck,
                'pending'  => Icon::Clock,
                'archived' => Icon::Archive,
                default    => Icon::Circle,
            })
            ->color(fn (string $state): string => match ($state) {
                'active'   => 'success',
                'pending'  => 'warning',
                default    => 'secondary',
            })
            ->size(IconSize::Large)
            ->tooltips([
                'active'   => 'Account is active',
                'pending'  => 'Awaiting confirmation',
                'archived' => 'No longer active',
            ]);
    }

    protected function mapRow(mixed $row): array
    {
        return [
            'name'   => $row->getName(),
            'status' => $row->getStatus(),
        ];
    }
}