---
title: "date-picker"
description: "Input-style button that opens a calendar popover. Single date or range, min\/max, keyboard navigation, localized month and day names, submits Y-m-d with the form."
category: "Forms"
---
# date-picker
Input-style button that opens a calendar popover. Single date or range, min/max, keyboard navigation, localized month and day names, submits Y-m-d with the form.
## Installation
```bash
php artisan ui:add date-picker
```
## Dependencies
- composer: `gehrisandro/tailwind-merge-laravel`
## Usage
```blade
{{-- Initial value, limits, Monday as the first day of the week --}}
{{-- Range: submits one value, "2026-12-01,2026-12-07" --}}
{{-- wire:model and x-model go to the hidden input --}}
```
## Example
The demo rendered on the docs page.
```blade
@php
// In a real app these come from the controller.
$dueAt = now()->addDays(3)->format('Y-m-d');
$earliest = now()->format('Y-m-d');
@endphp
```
## Source
Copy this file to the path shown above it.
`resources/views/components/ui/date-picker.blade.php`
```blade
@props([
'name' => null,
'value' => null,
'mode' => 'single',
'placeholder' => 'Pick a date',
'min' => null,
'max' => null,
'disabled' => false,
'locale' => null,
'weekStartsOn' => 0,
'previousLabel' => 'Previous month',
'nextLabel' => 'Next month',
])
@php
$mode = match ($mode) {
'range' => 'range',
default => 'single',
};
$uid = 'date-picker-' . bin2hex(random_bytes(4));
// The trigger label is rendered here so it reads right before any script
// runs. The script re-renders it with the page's once loaded.
$labelLocale = $locale ?? (function_exists('app') ? str_replace('_', '-', app()->getLocale()) : 'en');
$dates = [];
foreach (explode(',', (string) $value) as $part) {
$date = \DateTimeImmutable::createFromFormat('!Y-m-d', trim($part));
if ($date) {
$dates[] = $date;
}
}
$format = function (\DateTimeImmutable $date) use ($labelLocale) {
if (! class_exists(\IntlDatePatternGenerator::class)) {
return $date->format('Y-m-d');
}
// Same skeleton as the script's Intl options (year, short month, day).
$pattern = (new \IntlDatePatternGenerator($labelLocale))->getBestPattern('yMMMd');
return (new \IntlDateFormatter($labelLocale, \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, null, null, $pattern))->format($date);
};
$label = implode(' - ', array_map($format, $dates));
$classes = \TailwindMerge\Laravel\Facades\TailwindMerge::merge(
'flex h-9 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-start text-sm shadow-xs outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[empty=true]:text-muted-foreground',
$attributes->get('class'),
);
// `id` and aria-* describe the visible control, so a