Search by

coolsam / flatpickr

coolsam726

Flatpickr input for Filamentphp

Package info

github.com/coolsam726/flatpickr

pkg:composer/coolsam/flatpickr

Fund package maintenance!

coolsam

Statistics

Installs: 425 911

Dependents: 2

Suggesters: 0

Stars: 101

Open Issues: 0

v5.4.0 2026-12-05 04:25 UTC

README

Filament Flatpickr: date, time, week, month, year, and multiple-date pickers

Flatpickr-powered date, time, week, month, year, and multiple-date pickers for Filament.

CI Coverage Latest Version on Packagist Total Downloads Plumb score

Supported versions

Package Filament Laravel PHP
v5.x (current) 4.x, 5.x 11.x – 13.x 8.2 – 8.5 (PHP 8.5 from Laravel 12+; Laravel 13 from PHP 8.3+)
v4.x 3.x 10.x – 11.x 8.1 – 8.3
v2.x 2.x 9.x – 10.x 8.0 – 8.2

Installation

Install the package with Composer:

composer require coolsam/flatpickr

Publish assets and configuration:

php artisan flatpickr:install

This publishes config/flatpickr.php and assets to public/vendor/flatpickr. You will be prompted to overwrite existing files when upgrading.

After upgrading, refresh Filament assets:

php artisan filament:upgrade

Quick start

use Coolsam\Flatpickr\Forms\Components\Flatpickr;

Flatpickr::make('published_at')
    ->format('Y-m-d')
    ->minDate(today()->startOfYear())
    ->maxDate(today());

Picker modes

One component covers every Flatpickr mode you need:

Mode Helper Typical format
Date Flatpickr::make('date') Y-m-d
Date & time ->time(true) or ->timePicker() Y-m-d H:i / H:i
Range ->rangePicker() joined string by default; ->asArray() for ['start', 'end']; or two fields with ->rangeEnd()
Multiple dates ->multiplePicker() array of date strings
Week ->weekPicker() W Y
Month ->monthPicker() Y-m
Year ->yearPicker() Y

Short examples

use Coolsam\Flatpickr\Forms\Components\Flatpickr;

Flatpickr::make('start_time')->timePicker();
Flatpickr::make('week_number')->weekPicker()->format('W Y');
Flatpickr::make('month')->monthPicker()->format('Y-m')->displayFormat('F Y');
Flatpickr::make('year')->yearPicker(); // two-decade nav + 4×5 year grid
Flatpickr::make('range')->rangePicker();
Flatpickr::make('range_array')->rangePicker()->asArray(); // live state: ['2026-01-01', '2026-12-31']
Flatpickr::make('starts_at')->rangePicker()->rangeEnd('ends_at')->format('Y-m-d');
Flatpickr::make('occupied_slots')->multiplePicker()->format('Y-m-d')->displayFormat('F j, Y');

Configuration

Most fluent methods mirror Flatpickr's options. The API is inspired by Filament's date/time fields and works as a drop-in alternative with Flatpickr-specific behaviour.

Inputs are readonly by default (picker-only). Call ->allowInput() when users should type dates as well.

use Coolsam\Flatpickr\Enums\FlatpickrMode;
use Coolsam\Flatpickr\Enums\FlatpickrMonthSelectorType;
use Coolsam\Flatpickr\Enums\FlatpickrPosition;
use Coolsam\Flatpickr\Forms\Components\Flatpickr;

Flatpickr::make('event_date')
    ->format('Y-m-d')
    ->displayFormat('F j, Y')
    ->allowInput() // optional: enable typing; omit for picker-only
    ->altInput()
    ->minDate(fn () => today()->startOfYear())
    ->maxDate(fn () => today())
    ->disableDates(['2024-07-25', '2024-07-26'])
    ->rangeSeparator(' to ')
    ->conjunction(',')
    ->hourIncrement(1)
    ->minuteIncrement(10)
    ->seconds(false)
    ->weekNumbers()
    ->time24hr()
    ->inline()
    ->disableMobile()
    ->mode(FlatpickrMode::RANGE) // or ->rangePicker(), ->multiplePicker()
    ->monthSelectorType(FlatpickrMonthSelectorType::DROPDOWN)
    ->position(FlatpickrPosition::AUTO_CENTER)
    ->showMonths(2)
    ->timePicker()
    ->weekPicker()
    ->monthPicker()
    ->yearPicker()
    ->rangePicker()
    ->multiplePicker();

See the Flatpickr documentation for details on each option.

State types

Picker Live form state Dehydrated state
Date, time, week, month, year string string or CarbonInterface
Range (default) Joined string, e.g. "2026-01-01 to 2026-12-31" array of two date strings
Range with ->asArray() ['2026-01-01', '2026-12-31'] Same array (parsed/formatted)
Multiple Joined string (conjunction) array of date strings
Range with ->rangeEnd('ends_at') Start-only on the field + end-only on ends_at Two separate field values

Range as an array (asArray)

By default the picker binds a single joined string while you edit. Opt into an array of two dates for live Livewire state (and hydration) with ->asArray():

Flatpickr::make('booking_period')
    ->rangePicker()
    ->asArray()
    ->format('Y-m-d');

// Live + dehydrated: ['2026-01-01', '2026-12-31']

Use this when you want $get('booking_period') / afterStateUpdated to see an array without waiting for dehydrate. Do not combine asArray() with rangeEnd() — split fields already store two scalars.

Date range with asArray live state

Split range across two fields (rangeEnd)

When your model uses separate starts_at and ends_at columns, bind the range picker to the start field and name the end field explicitly. The package renders a grouped Start | End pair that shares one range calendar. Do not add a second Flatpickr on ends_at.

Flatpickr::make('starts_at')
    ->label('Event dates')
    ->rangePicker()
    ->rangeEnd('ends_at')
    ->format('Y-m-d');

Grouped Start | End inputs with split Livewire state

Dual-input behaviour

Focus Calendar behaviour
Start Begins a fresh two-click range (Livewire unchanged until a complete range is chosen). If both dates are already set, the calendar still shows that selection until the first new click.
End (start set) Next click sets end only. If both dates are set, the committed range is painted; calendar jumps to the end month when end is set, otherwise the start month.
End (start empty) Same as a fresh pick; calendar opens on today.
Close mid-range Incomplete picks do not change Livewire; Start/End displays revert to the committed state.

Validation rules on ends_at (for example after:starts_at) still work because the end value is kept in sync while the user selects a complete range. Datetime ranges keep each date’s own time when the user picks in reverse chronological order.

Shared range calendar opened from the End input

Date & time range

Use ->time(true) with a format that includes hours and minutes. displayFormat() controls what the user sees in the inputs (Flatpickr tokens, not PHP date() tokens). Storage and dehydration still use format().

Flatpickr::make('starts_at')
    ->label('Event schedule')
    ->rangePicker()
    ->rangeEnd('ends_at')
    ->time(true)
    ->format('Y-m-d H:i')              // saved to starts_at / ends_at
    ->displayFormat('M j, Y h:i K')    // e.g. Jun 14, 2024 7:00 AM
    ->rangeSeparator(' to ');

Ensure your model casts both columns as datetime.

See RFC 0001 for the full design.

Input editing (allowInput)

Flatpickr inputs are readonly by default so values come from the picker. Call ->allowInput() when users should type as well (display and value formats are both accepted where typed input is enabled).

Themes

Set the global theme in config/flatpickr.php using a FlatpickrTheme enum value:

use Coolsam\Flatpickr\Enums\FlatpickrTheme;

return [
    'theme' => FlatpickrTheme::DEFAULT, // recommended
];

Recommendation: Use the DEFAULT theme. It is styled with Tailwind to match Filament, including dark mode. Bundled Flatpickr themes may not align with your panel styling.

The theme is registered once as a Filament asset and loaded in the page head, before your panel theme. After changing it, run php artisan filament:assets so the new stylesheet is published.

Theme previews are included in the screenshots below.

Screenshots

Picker modes

Single date

Single date picker

Multiple dates

Multiple date picker

Date range

Date range picker

Date range (asArray)

Date range with asArray live state

Split range (rangeEnd)

Grouped Start | End inputs

Shared range calendar for dual inputs

Date & time

Date-time picker

Time only

Time-only picker

Multiple months

Show multiple months

Week

Week picker

Month

Month picker

Year

->yearPicker() opens a custom 4×5 year grid covering two decades, with prev/next stepping by 20 years. There is no upstream Flatpickr yearSelect plugin — this package ships its own.

Theme gallery

Default (recommended)

Default theme

Airbnb

Airbnb theme

Light

Light theme

Dark

Dark theme

Confetti

Confetti theme

Material Blue

Material Blue theme

Material Green

Material Green theme

Material Orange

Material Orange theme

Material Red

Material Red theme

Testing

composer test

Changelog

See CHANGELOG for release notes.

Contributing

See CONTRIBUTING for guidelines.

Security

Report vulnerabilities according to our security policy.

Credits

License

The MIT License. See LICENSE.md.