PHPackages                             madbox-99/filament-essentials - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. madbox-99/filament-essentials

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

madbox-99/filament-essentials
=============================

Essential default configurations and macros for Filament PHP

v1.0.0(9mo ago)115MITPHPPHP ^8.1

Since Jul 18Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/MadBox-99/filament-essentials)[ Packagist](https://packagist.org/packages/madbox-99/filament-essentials)[ RSS](/packages/madbox-99-filament-essentials/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Filament Essentials
===================

[](#filament-essentials)

Essential default configurations for Filament PHP. This package **automatically** sets up default options for every Filament form component, so you don't need to call any macros or functions separately.

Installation
------------

[](#installation)

```
composer require madbox-99/filament-essentials
```

The package is automatically registered in Laravel through package discovery and **immediately** starts working with every new Filament component.

### Optional translatable functionality

[](#optional-translatable-functionality)

If you want to use the `translatable()` function, install the following package as well:

```
composer require spatie/laravel-translatable
```

Or use any other translation package that provides the `translatable()` method for Filament components.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag="filament-essentials-config"
```

This creates the `config/filament-essentials.php` file where you can customize the default settings.

Usage
-----

[](#usage)

### Automatic operation

[](#automatic-operation)

**No extra code needed!** After installing the package, every Filament form component automatically gets the default settings:

```
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\Select;

// Previously you would have needed:
TextInput::make('name')
    ->translateLabel()
    ->maxLength(255),

// Now simply:
TextInput::make('name'),
// ↑ Automatically 255 character limit (AND translateLabel() if enabled)!

// Field labels are automatically translated based on Laravel lang files (if enabled)
```

### Automatically applied settings

[](#automatically-applied-settings)

- **TextInput** - Automatically `maxLength(255)`, optionally `translateLabel()`
- **Textarea** - Automatically `maxLength(1000)`, `rows(3)`, optionally `translateLabel()`
- **RichEditor** - Custom toolbar, optionally `translateLabel()`
- **Select** - Automatically `searchable(true)`, `preload(false)`, optionally `translateLabel()`
- **DatePicker** - Hungarian date format (Y-m-d → Y. m. d.), optionally `translateLabel()`
- **TimePicker** - 24-hour format (H:i), optionally `translateLabel()`
- **DateTimePicker** - Hungarian date-time format, optionally `translateLabel()`
- **Toggle** - `onColor('success')`, `offColor('gray')`, optionally `translateLabel()`
- **Checkbox** - Optionally `translateLabel()`
- **CheckboxList** - `searchable(true)`, `bulkToggleable(true)`, optionally `translateLabel()`
- **Radio** - Optionally `translateLabel()`
- **FileUpload** - `maxSize(2048)` KB, PDF and images, `downloadable(true)`, `previewable(true)`, optionally `translateLabel()`

### TranslateLabel function

[](#translatelabel-function)

The `translateLabel()` is **disabled by default**, but it's safe to enable. This automatically translates field labels based on Laravel localization files.

```
// For example, if you have in resources/lang/en/validation.php:
'attributes' => [
    'name' => 'Name',
    'email' => 'Email Address',
]

// Then TextInput::make('name') will automatically show "Name" as the label
```

If you want to use this feature:

```
// config/filament-essentials.php
'default_translatable' => true,
```

### Facade usage

[](#facade-usage)

```
use FilamentEssentials\Facades\FilamentEssentials;

// Get configuration values
$isTranslatable = FilamentEssentials::isTranslatableByDefault(); // false
$config = FilamentEssentials::getDefaultConfig(); // all configuration
```

### Overriding individual settings

[](#overriding-individual-settings)

If you want different settings for a specific component, simply add them:

```
TextInput::make('special_field')
    ->maxLength(500)  // Overrides the default 255
    ->required(),     // Add required() if needed
```

Configuration
-------------

[](#configuration-1)

You can modify the default settings in the `config/filament-essentials.php` file:

```
return [
    'default_translatable' => false,       // Make every field translateLabel()
    'default_max_length' => 255,          // TextInput max length
    'default_textarea_max_length' => 1000, // Textarea max length
    'default_textarea_rows' => 3,         // Textarea row count
    'default_textarea_cols' => 50,        // Textarea column count

    // Select settings
    'default_select_searchable' => true,
    'default_select_preload' => false,

    // Date formats
    'default_date_format' => 'Y-m-d',
    'default_date_display_format' => 'Y. m. d.',
    'default_time_format' => 'H:i',
    'default_time_display_format' => 'H:i',
    'default_datetime_format' => 'Y-m-d H:i:s',
    'default_datetime_display_format' => 'Y. m. d. H:i',

    // Toggle colors
    'default_toggle_on_color' => 'success',
    'default_toggle_off_color' => 'gray',

    // CheckboxList settings
    'default_checkbox_list_searchable' => true,
    'default_checkbox_list_bulk_toggleable' => true,

    // File upload
    'default_file_max_size' => 2048, // KB
    'default_file_types' => ['application/pdf', 'image/*'],
    'default_file_downloadable' => true,
    'default_file_previewable' => true,

    // RichEditor toolbar settings
    'rich_editor_toolbar' => [
        'attachFiles', 'blockquote', 'bold', 'bulletList', 'codeBlock',
        'h2', 'h3', 'italic', 'link', 'orderedList', 'redo',
        'strike', 'underline', 'undo',
    ],
];
```

Example usage
-------------

[](#example-usage)

```
