madbox-99 / filament-essentials
Sensible defaults for Filament: translated labels on every field, entry and column, plus optional component defaults.
Requires
- php: ^8.3
- filament/filament: ^5.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Sensible defaults for Filament. Once installed, every form field, infolist entry,
table column and wizard step translates its label through Laravel's __()
helper, so you never have to call ->translateLabel() again. Opinionated
component defaults (max lengths, searchable selects, Hungarian date formats,
upload limits) are available as an opt-in.
Installation
composer require madbox-99/filament-essentials
The service provider is auto-discovered. There is nothing else to set up.
Translated labels
Filament derives a label from the component name (first_name becomes
First name). With this package that label is passed through __(), so a
single entry in lang/hu.json translates it everywhere it appears:
{
"First name": "Keresztnév"
}
TextInput::make('first_name'); // Keresztnév TextEntry::make('first_name'); // Keresztnév TextColumn::make('first_name'); // Keresztnév
The configuration is applied to Filament's base classes (Field, Entry,
Column, Step), so it reaches every built-in and custom subclass. Labels
without a translation render exactly as stock Filament.
To opt a single component out:
TextInput::make('first_name')->translateLabel(false);
Component defaults (opt-in)
Publish the config and enable them:
php artisan vendor:publish --tag=filament-essentials-config
// config/filament-essentials.php 'component_defaults' => true,
| Component | Default |
|---|---|
TextInput |
maxLength(255) |
Textarea |
maxLength(1000), rows(3) |
RichEditor |
a fixed toolbar |
Select |
searchable(), no preload |
DatePicker, TimePicker, DateTimePicker |
Hungarian display formats |
Toggle |
onColor('success'), offColor('gray') |
CheckboxList |
searchable(), bulkToggleable() |
FileUpload |
2 MB, PDF and images, downloadable, previewable |
Every value is configurable, and anything set on the component itself still wins:
TextInput::make('notes')->maxLength(500);
Configuration
return [ 'translate_labels' => true, 'component_defaults' => false, // ...the individual component defaults ];
Requirements
- PHP 8.3+
- Filament 5
Upgrading from 1.x
- The namespace is now
MadBox99\FilamentEssentials; the facade was removed. default_translatableis nowtranslate_labelsand is on by default. It also covers infolist entries and every table column.- Component defaults are off unless
component_defaultsistrue, and their keys lost thedefault_prefix (default_max_lengthis nowtext_input_max_length).
Testing
composer test
License
MIT. See LICENSE.