信息列表
Color entry
简介
颜色条目(ColorEntry)允许你使用 CSS 颜色定义展示颜色预览,通常使用拾色器(ColoPicker)字段获得。颜色支持的格式有(HEX、HSL、RGB、RGBA)。
use Filament\Infolists\Components\ColorEntry;
ColorEntry::make('color')

允许将颜色复制到剪切板
你可以让颜色可复制(copyable),比如在预览上单击将 CSS 值复制到剪切板,且可选地指定自定义确认消息及时长(以毫秒计)。该特性只有在应用启用 SSL 时有效:
use Filament\Infolists\Components\ColorEntry;
ColorEntry::make('color')
->copyable()
->copyMessage('Copied!')
->copyMessageDuration(1500)

此外,你也可以传入一个布尔值,控制颜色是否可复制:
use Filament\Infolists\Components\ColorEntry;
ColorEntry::make('color')
->copyable(FeatureFlag::active())
除了允许静态值之外,copyable()
、copyMessage()
和 copyMessageDuration()
方法也接受函数以动态计算它们的值。你可以将多个 utility 作为参数注入到这些函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
Still need help? Join our Discord community or open a GitHub discussion