Skip to content
Version 4.x
Theme

Color entry

View as Markdown

On this page

#Introduction

The color entry allows you to show the color preview from a CSS color definition, typically entered using the color picker field, in one of the supported formats (HEX, HSL, RGB, RGBA).

use Filament\Infolists\Components\ColorEntry;

ColorEntry::make('color')
Color entry

#Allowing the color to be copied to the clipboard

You may make the color copyable, such that clicking on the preview copies the CSS value to the clipboard, and optionally specify a custom confirmation message and duration in milliseconds. This feature only works when SSL is enabled for the app.

use Filament\Infolists\Components\ColorEntry;

ColorEntry::make('color')
    ->copyable()
    ->copyMessage('Copied!')
    ->copyMessageDuration(1500)
Color entry with a button to copy it

Optionally, you may pass a boolean value to control if the color should be copyable or not:

use Filament\Infolists\Components\ColorEntry;

ColorEntry::make('color')
    ->copyable(FeatureFlag::active())

As well as allowing static values, the copyable(), copyMessage(), and copyMessageDuration() methods also accept functions to dynamically calculate them. You can inject various utilities into the function as parameters.

Entry $component Filament\Infolists\Components\Entry

The current entry component instance.

Get function $get Filament\Schemas\Components\Utilities\Get

A function for retrieving values from the current schema data. Validation is not run on form fields.

Livewire $livewire Livewire\Component

The Livewire component instance.

Eloquent model FQN $model ?string<Illuminate\Database\Eloquent\Model>

The Eloquent model FQN for the current schema.

Operation $operation string

The current operation being performed by the schema. Usually create, edit, or view.

Parent repeater item index $parentRepeaterItemIndex int

The zero-based index of the nearest containing repeater item or builder block, or 0 when neither exists.

Record $record Illuminate\Database\Eloquent\Model|array<string, mixed>|null

The Eloquent record or custom data array for the current schema.

Related record $relatedRecord Illuminate\Database\Eloquent\Model

The current related Eloquent record for the rendered item.

State $state mixed

The current value of the entry.

Documentation menu Star on GitHub