by Samson Maosa
The Popular Date/time Picker, Flatpickr, as a Filament Form Field
Flatpickr is one of the most popular js datepickers. This filament plugin allows you to use flatpickr as a Filament Field without the sweat of configuration.
You can install the package via composer:
composer require savannabits/filament-flatpickr
You can publish the config file with:
php artisan vendor:publish --tag="filament-flatpickr-config"
This is the contents of the published config file:
return [ 'default_theme' => 'airbnb', // 'default','dark','material_blue','material_green','material_red','material_orange','airbnb','confetti'];
If you are using a custom filament theme (using tailwind.config.js), append the following to tailwind.config.js
under content
for proper styling:
module.exports = { content: [ ..., './vendor/savannabits/filament-flatpickr/**/*.blade.php', // <== Add this line ],
Use the Flatpickr
field anywhere in your filament forms as shown in the following examples
use Savannabits\Flatpickr\Flatpickr; // Basic, Date FieldFlatpickr::make('read_at')->default(now()),
// Datetime fieldFlatpickr::make('read_at')->enableTime(),
// Month Selector fieldFlatpickr::make('read_at')->monthSelect(),
// Date Range picker fieldFlatpickr::make('read_at')->rangePicker(),
// Specify the Date formatFlatpickr::make('read_at')->dateFormat('Y-m-d'), // Toggle AltInput (true by default) and set Alt Display Format:Flatpickr::make('read_at')->altInput(true)->altFormat('F J Y'),
// Specify the input Date FormatFlatpickr::make('read_at')->dateFormat('d/m/Y')->altInput(false),
// Specify the Datepicker's Theme: See for https://flatpickr.js.org/themes/ available themesFlatpickr::make('read_at')->theme('material_red'),
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.