Documentation Index
Fetch the complete documentation index at: https://mintlify.com/filamentphp/filament/llms.txt
Use this file to discover all available pages before exploring further.
The key-value component allows you to interact with one-dimensional key-value pairs.
Basic Usage
use Filament\Forms\Components\KeyValue;
KeyValue::make('metadata')
Available Methods
Sets the label for the key column.KeyValue::make('metadata')
->keyLabel('Property name')
Sets the label for the value column.KeyValue::make('metadata')
->valueLabel('Property value')
Sets placeholder for key inputs.KeyValue::make('metadata')
->keyPlaceholder('Key')
Sets placeholder for value inputs.KeyValue::make('metadata')
->valuePlaceholder('Value')
Customizes the add button label.KeyValue::make('metadata')
->addActionLabel('Add property')
Controls whether items can be added.KeyValue::make('metadata')
->addable(false)
Controls whether items can be deleted.KeyValue::make('metadata')
->deletable(false)
Controls whether items can be reordered.KeyValue::make('metadata')
->reorderable()
Controls whether keys can be edited.KeyValue::make('settings')
->editableKeys(false)
Common Patterns
KeyValue::make('metadata')
->keyLabel('Property')
->valueLabel('Value')
->reorderable()
Configuration Settings
KeyValue::make('settings')
->keyLabel('Setting')
->valueLabel('Value')
->keyPlaceholder('Setting name')
->valuePlaceholder('Setting value')
->addActionLabel('Add setting')
Custom Attributes
KeyValue::make('attributes')
->keyLabel('Attribute')
->valueLabel('Value')
->reorderable()
->addActionLabel('Add attribute')
Fixed Keys
KeyValue::make('social_links')
->editableKeys(false)
->default([
'twitter' => '',
'facebook' => '',
'instagram' => '',
'linkedin' => '',
])
Database Casting
Add an array cast:
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected function casts(): array
{
return [
'metadata' => 'array',
];
}
}