Skip to content
Bladewell

<x-widget.datepicker>

Date picker Blade component for Laravel and Livewire

Single date field with a calendar popover. Submits Y-m-d; validate with NotAfterToday, or MinimumAge for birthday. Works with Livewire wire:model, name optional.

php artisan bladewell:add datepicker
Also adds
Icon
Used by
Date range picker, Filter builder
Needs PHP extension
intl
Works with
Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+
Guides
Build a Laravel form from your validation rules · Using Blade components in Livewire 3 and 4

Usage

In other languages

Dates, month and weekday names, the week's first day and digits follow the app locale (app()->getLocale()). For Arabic, Hebrew, Persian or Urdu, set dir="rtl" and the calendar mirrors, keyboard included. The picker's own labels are plain English in the component file; edit them there.

Blade
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" dir="{{ in_array(app()->getLocale(), ['ar', 'he', 'fa', 'ur']) ? 'rtl' : 'ltr' }}">

{{-- Or set them per picker: --}}
<x-widget.datepicker name="start_date" label="Datum" locale="de" :week-start="0" />

Livewire

In a Livewire component, bind with wire:model (deferred) or wire:model.live to a string property holding YYYY-MM-DD, or null: public ?string $due = null. No name is needed. The field shows the property after every render, and a date set or cleared in PHP shows too; the calendar opens on it. Validate it like any date: 'due' => ['required', 'date'].

Blade
<div>
    <x-widget.datepicker label="Due date" wire:model.live="due" :max="false" />

    <x-widget.datepicker label="Date of birth" wire:model="birthday" birthday />
</div>

On the server

The date picker can't stop a request that skips it. Here's what to check on your server.

Security

  • Its max of today is the person's today, but before_or_equal:today on the server uses the server's configured timezone, and the two can be on different dates: near midnight it turns away a real today or lets tomorrow through. Validate with NotAfterToday (or MinimumAge for birthdays), which come with it, and date_format:Y-m-d.

    Laravel: The date_format rule

Examples

Basic

Submits Y-m-d, up to today by default: for dates ahead, see the future example. Validate it with new NotAfterToday, not before_or_equal:today, which uses the server's UTC date.

Show code
Blade
<x-widget.datepicker name="start_date" label="Start date" class="max-w-xs" />

Future

For a deadline or an appointment: from today, no upper limit. Without :max="false" the calendar stops at today, its default for dates that have already happened.

Show code
Blade
<x-widget.datepicker name="due_date" label="Due date" min="today" :max="false" class="max-w-xs" />

Birthday

Only allows dates at least 18 years back. Pair it with new MinimumAge(18) on the server.

You must be 18 or older.

Show code
Blade
<x-widget.datepicker name="date_of_birth" label="Date of birth" birthday class="max-w-xs" />

States

Please choose a valid date.

Show code
Blade
<div class="grid gap-6 sm:grid-cols-2">
    <x-widget.datepicker name="due_date" label="With error" value="2026-09-01" error="Please choose a valid date." />
    <x-widget.datepicker name="locked_date" label="Disabled" disabled />
</div>

Props

Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.

<x-widget.datepicker>

Prop Default Description
name null What the date submits as (YYYY-MM-DD). Optional with wire:model, which then names it.
id null Defaults to one made from the name (or the wire:model property).
label null Shown above the field, and its name for screen readers.
value null The date: YYYY-MM-DD or a date object. Old input wins after a failed submit; with wire:model and no value, the bound property.
placeholder null Shown while no date is picked; "Choose a date" by default.
error null An error message of your own; otherwise the validation error for the name, from the session or Livewire.
info null A hint under the field.
bag 'default' Which error bag to read the error from.
disabled false Greyed out: it can't be opened.
readonly false Shown, and submitted, but it can't be changed: the button opens nothing. With disabled, disabled wins.
min null The earliest date that can be picked: YYYY-MM-DD, a date object, or "today" (the visitor's today).
max 'today' The latest date: YYYY-MM-DD, a date object, "today" (the default), or false for no limit.
birthday false A date-of-birth picker: true for 18 or older, or a number for another minimum age. Sets max and the hint to match.
week-start null The first day of the week, 0 (Sunday) to 6 (Saturday); defaults to the locale's.
locale null The language for month and day names and the date shown (en, fr, ar…); defaults to the app's.
required-message 'Choose a date.' With required: the message when nothing is picked.

Accessibility

All 4 examples above are checked with axe-core against the WCAG 2.2 A and AA rules, in the light theme and the dark one, both as the page draws and with each popover, dialog, toast and tooltip opened, on every change. A change that fails can't be merged. Where axe can't decide, such as contrast on SVG text, the test measures the colours itself instead of letting it pass.

Automated checks can't judge everything: how it sounds in a screen reader, and how it feels to use from the keyboard, still need a person. Check those on your own pages too.

Source

What bladewell:add datepicker writes to your app with the default namespaces. Prefer to copy by hand? Take these files, plus the ones from the components it also adds and Field, and the theme and base CSS.

resources/views/components/widget/datepicker/index.blade.php Show
index.blade.php
resources/js/widget/datepicker/index.js Show
index.js
app/View/Widget/ElementIds.php Show
ElementIds.php
app/View/Widget/FormField.php Show
FormField.php
app/View/Widget/LocalDate.php Show
LocalDate.php
app/Rules/LocalToday.php Show
LocalToday.php
app/Rules/MinimumAge.php Show
MinimumAge.php
app/Rules/NotAfterToday.php Show
NotAfterToday.php