K

Table

ColorColumn

A stored CSS colour as a swatch beside its literal value — the table counterpart of the infolist's colour entry.

On this page

Renders a stored CSS color as a swatch next to its literal value. The table-side counterpart of the infolist ColorEntry.

use NyonCode\WireTable\Columns\ColorColumn;

Basic Usage

ColorColumn::make('brand_color') // "#1a2b3c" → swatch + "#1a2b3c"

The state is a CSS color stored on the record — hex, rgb(), hsl(), or a keyword. It is not a palette name: for palette-driven coloring (a status pill, a state icon) use BadgeColumn or IconColumn.

Swatch Only

Drop the literal value where the column is narrow and the swatch is enough:

ColorColumn::make('brand_color')
->swatchOnly()

Copy to Clipboard

The shared copyable() API copies the color value:

ColorColumn::make('brand_color')
->copyable()

Values it will not draw

A swatch is the one cell that puts record data into a style attribute, where HTML escaping alone is not enough — ; would open a second declaration. Values that are not a recognisable CSS color are rejected and the cell falls back to its empty text:

// Rendered: #1a2b3c, rgb(255 0 0 / 50%), rebeccapurple
// Not rendered: "red; background-image: url(…)", "url(…)", "expression(…)"

ColorColumn API

->swatchOnly(bool $condition = true) // hide the literal value beside the swatch
->isSwatchOnly(): bool