coolsam / flatpickr
Flatpickr input for Filamentphp
Fund package maintenance!
coolsam
Requires
- php: ^8.2
- filament/filament: ^3
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- barryvdh/laravel-ide-helper: ^3.5
- laravel/pint: ^1.0
- nunomaduro/larastan: ^3.1.0
- orchestra/testbench: ^9.12
- pestphp/pest-plugin-laravel: ^3.1
- pestphp/pest-plugin-livewire: ^3.0
- phpstan/extension-installer: ^1.4.3
- spatie/laravel-ray: ^1.39
- dev-main
- v4.0.0
- 3.x-dev
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.1
- 3.0.0
- 2.x-dev
- v2.0.0
- v1.1.0
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-4.x-dev
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-5
- dev-dependabot/github_actions/actions/deploy-pages-4
- dev-dependabot/github_actions/ramsey/composer-install-3
- dev-dependabot/github_actions/actions/checkout-4
- dev-dependabot/github_actions/actions/configure-pages-5
- dev-dependabot/github_actions/dependabot/fetch-metadata-2.3.0
- dev-coolsam726-laravel-10
- dev-flatpickr-config-patch
This package is auto-updated.
Last update: 2025-04-13 16:21:43 UTC
README
Use Flatpickr as your datepicker in the Filament Forms and Panels.
Supported Versions
Package Version | Supported Filament Version(s) |
---|---|
v2.x | Filament v2 |
v3.x | Filament v3 |
v4.x | Filament v3, Filament v4 |
Installation
Install the package via composer:
composer require coolsam/flatpickr
php artisan flatpickr:install
If you are upgrading from a previous version be sure to run the following to ensure assets are up to date
php artisan filament:upgrade
Usage
You can do a lot with just one Component: Flatpickr
You can use the Flatpickr component from this package as:
- DatePicker
- TimePicker
- DateTimePicker
- Range Picker
- Week Picker,
- Multiple-Date Picker
- Month Picker
Most of the fluent config methods are similar to Flatpickr's official options in naming.
This package is also an extension of Filament's DateTimePicker, so most of the methods are similar to the ones in the DateTimePicker component. You can use the Flatpickr component as a drop-in replacement for the DateTimePicker component.
Here are some examples of the methods. Refer to Flatpickr's Official Documentation for details on each of the configurations.
use Coolsam\FilamentFlatpickr\Forms\Components\Flatpickr; // Basic, Date Field Flatpickr::make('test_field') // Minimal Config as a datepicker Flatpickr::make('test_field') ->allowInput() // Allow a user to manually input the date in the textbox (make the textbox editable) ->altInput(true) // Enable the use of Alternative Input (See Flatpickr docs) ->altFormat('F j, Y') // Alternative input format ->time(true) // Turn this into a DateTimePicker ->disabledDates(['2023-07-25','2023-07-26']) // Disable specific dates from being selected. ->minDate(fn() => today()->startOfYear()) // Set the minimum allowed date ->maxDate(fn() => today()) // Set the maximum allowed date. ->hourIncrement(1) // Intervals of incrementing hours in a time picker ->minuteIncrement(10) // Intervals of minute increment in a time picker ->seconds(false) // Enable seconds in a time picker ->defaultSeconds(0) //Initial value of the seconds element, when no date is selected ->defaultMinute(0) // Initial value of the minutes element, when no date is selected ->allowInvalidPreload() // Initially check if the selected date is valid ->altInputClass('sample-class') // Add a css class for the alt input format ->animate() // Animate transitions in the datepicker. ->format('Y-m-d') // Set the main date format ->ariaDateFormat('Y-m-d') // Aria ->clickOpens(true) // Open the datepicker when the input is clicked. ->closeOnSelect(true) // Close the datepicker once the date is selected. ->conjunction(',') // Applicable only for the MultiDatePicker: Separate inputs using this conjunction. The package will use this conjunction to explode the inputs to an array. ->inline(true) // Display the datepicker inline with the input, instead of using a popover. ->disableMobile(true) // Disable mobile-version of the datepicker on mobile devices. ->mode(\Coolsam\FilamentFlatpickr\Enums\FlatpickrMode::RANGE) // Set the mode as single, range or multiple. Alternatively, you can just use ->range() or ->multiple() ->monthSelectorType(\Coolsam\FilamentFlatpickr\Enums\FlatpickrMonthSelectorType::DROPDOWN) ->shorthandCurrentMonth(true) ->noCalendar(true) // use this in conjunction with `time()` to have a timePicker ->position(\Coolsam\FilamentFlatpickr\Enums\FlatpickrPosition::AUTO_CENTER) ->showMonths(1) ->weekNumbers(true) ->use24hr(true) ->wrap(true) ->timePicker() // Configure a timepicker out of the box ->weekPicker() // configure a week picker out of the box ->monthPicker() // configure a month picker out of the box ->rangePicker() // configure a date range picker out of the box ->multiplePicker() // Configure a multiple date picker out of the box ;
Examples
// You can also use the component as a DateTimePicker, Range Picker, Week Picker, Month Picker, TimePicker and Multiple Date Picker \Coolsam\Flatpickr\Forms\Components\Flatpickr::make('start_time')->timePicker(), \Coolsam\Flatpickr\Forms\Components\Flatpickr::make('week_number')->weekPicker()->format('W Y'), \Coolsam\Flatpickr\Forms\Components\Flatpickr::make('month')->monthPicker()->format('Y-m')->displayFormat('F Y'), \Coolsam\Flatpickr\Forms\Components\Flatpickr::make('range')->rangePicker(), \Coolsam\Flatpickr\Forms\Components\Flatpickr::make('occupied_slots')->multiplePicker()->format('Y-m-d')->displayFormat('F j, Y'),
State Types
The package supports the following state types:
string
orCarbonInterface
for DateTimePicker, DatePicker, TimePicker, WeekPicker, MonthPickerarray
for RangePicker, MultiplePicker (an array of date strings or CarbonInterface instances)
Screenshots
Single Date Picker
Multiple Date Picker
Date Range Picker
Date-Time Picker
Time-Only Picker
Show Multiple Months
Week Picker
Month Picker
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.