The Date component provides an intuitive date picker interface for selecting dates. It supports various configuration options for date ranges, formats, and selection modes.
use TallStackUIFilament\Forms\Components\Date;
Date::make('birth_date')
->label('Birth Date'),Customize the date format with the format() method:
- You can use all Day.js formats.
- The formats are applicable only visually. The default backend format will always be YYYY-MM-DD
- The default date format sent to the component should be YYYY-MM-DD
Date::make('appointment_date')
->format('YYYY-MM-DD'), // Default format
Date::make('schedule_date')
->format('YYYY, MMMM, DD'),
Date::make('publication_date')
->format('DD [of] MMMM [of] YYYY'), // e.g., "Jan 1, 2023"Limit the selectable dates with min and max date constraints:
use Illuminate\Support\Carbon;
Date::make('event_date')
->minDate('2023-01-01'), // String date
Date::make('deadline')
->minDate(Carbon::now()), // Current date
Date::make('historical_date')
->maxDate('2023-12-31'),
Date::make('schedule_date')
->minDate(Carbon::now())
->maxDate(Carbon::now()->addMonths(3)),Limit the selectable years with min and max year constraints:
Date::make('birth_date')
->minYear(1950)
->maxYear(2023),Disable specific dates that cannot be selected:
Date::make('appointment_date')
->disableDates([
'2023-12-25', // Christmas
'2023-12-31', // New Year's Eve
]),
// Using Carbon instances
use Illuminate\Support\Carbon;
Date::make('meeting_date')
->disableDates([
Carbon::now()->addDays(1),
Carbon::now()->addDays(2),
]),
// Using a Collection
Date::make('delivery_date')
->disableDates(collect(['2023-12-25', '2023-12-26'])),Enable selecting a date range with the range() method:
Date::make('vacation_period')
->range(), // Allows selecting a date rangeEnable selecting multiple dates with the multiple() method:
Date::make('holiday_dates')
->multiple(), // Allows selecting multiple individual datesEnable selecting only month and year, without the specific day:
Date::make('credit_card_expiry')
->monthYearOnly(), // Shows only month and year pickerEnable date picker helper buttons (today, clear, etc.):
Date::make('start_date')
->helpers(), // Enables helper buttonsAdd a placeholder to guide users:
Date::make('event_date')
->placeholder('Select event date...'),use TallStackUIFilament\Forms\Components\Date;
use Illuminate\Support\Carbon;
Date::make('conference_dates')
->label('Conference Dates')
->format('MMM D, YYYY')
->minDate(Carbon::now())
->maxDate(Carbon::now()->addYear())
->minYear(Carbon::now()->year)
->maxYear(Carbon::now()->year + 2)
->disableDates([
Carbon::now()->next('Saturday'),
Carbon::now()->next('Sunday'),
])
->range()
->helpers()
->placeholder('Select conference dates')
->required(),Add validation rules as needed:
use Illuminate\Validation\Rules\Exists;
Date::make('departure_date')
->required()
->afterOrEqual('today'),Add custom HTML attributes to the input element:
Date::make('event_date')
->extraInputAttributes(['data-analytics' => 'date-selected']),