<x-widget.time-picker>
Time picker Blade component for Laravel and Livewire
A time of day, five ways: a list of times step minutes apart, hour and minute columns, segments typed straight into the field, a grid of slots for bookings, or the browser's own time field. Within min and max, on the locale's 12- or 24-hour clock, and always submits HH:MM. Works with Livewire wire:model, name optional.
php artisan bladewell:add time-picker
- Also adds
- Icon
- Needs PHP extension
intl- Works with
- Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+
Usage
Livewire
In a Livewire component, bind with wire:model (deferred) or wire:model.live to a string property holding HH:MM, or null: public ?string $start = null. No name is needed. Every variant shows the property after every render, so a time set or cleared in PHP shows too, and its errors are read under the property. Validate it as a time: 'start' => ['required', 'date_format:H:i'].
<form wire:submit="book" class="space-y-5">
<x-widget.time-picker label="Start" wire:model.live="start" min="08:00" max="18:00" :step="30" />
<x-widget.time-picker label="Reminder" variant="segmented" wire:model="reminder" />
<x-widget.time-picker label="Slot" variant="slots" :slots="$freeSlots" wire:model="slot" />
<button type="submit">Book</button>
</form>
On the server
The time picker can't stop a request that skips it. Here's what to check on your server.
Security
-
min,max,stepand the slots only limit what's offered. Validate withdate_format:H:i, and check the time against the same hours on the server. A time alone has no timezone: consider saving it with a date and the person's timezone, or a booking moves by an hour when the clocks change. -
With slots for bookings, check the slot is still free when the form arrives, in a transaction with a lock or a unique index: two people can pick the same one at once.
Examples
List
The default: a list of times, step minutes apart (15 by default) between min and max. Arrow keys move through it, and typing digits jumps: 9 to 9:00, 93 to 9:30. It submits HH:MM on a 24-hour clock. Like every input it fills the space it is given; a time needs about 12rem (class="max-w-48").
Show code Hide code
<x-widget.time-picker name="start" label="Start time" min="08:00" max="18:00" :step="30" value="09:30" class="max-w-48" />
Columns
variant="columns": hour, minute and, on a 12-hour clock, AM/PM columns, for any exact minute. The arrow keys turn each column, Left and Right move between them, and hours or minutes that would leave min and max are greyed out.
Show code Hide code
<x-widget.time-picker name="alarm" label="Alarm" variant="columns" value="07:45" :hour12="true" class="max-w-48" />
Segmented
variant="segmented": typed straight into the field, with no popover. Digits fill the hour and then the minute, the arrow keys change the part with focus, Left and Right move between parts, and A or P sets the period. Empty parts read hh, mm and AM/PM, and a hint shows an example to type (info="" hides it). Kept within min and max.
Type it as 09:30 PM
Show code Hide code
<x-widget.time-picker name="opens_at" label="Opens at" variant="segmented" min="06:00" max="23:00" class="max-w-48" />
Native
variant="native": the browser's own time field. On a phone or tablet it opens the device's time picker, which is easier to use by touch than typing into segments; on a computer it's typed with the keyboard. The browser checks required, min, max and step, and it submits HH:MM like the other variants. It writes the time the browser's way, so hour12 and locale don't apply.
Show code Hide code
<x-widget.time-picker name="pickup_at" label="Pick-up time" variant="native" min="08:00" max="20:00" :step="15" class="max-w-48" />
Slots
variant="slots": a grid of times to choose one of, for bookings. Pass the times with :slots, marking taken ones disabled, or leave it out for every time from min to max. They're real radio buttons, so the arrow keys and required work with no script.
Show code Hide code
<x-widget.time-picker name="appointment" label="Appointment" variant="slots" :slots="[
'09:00', '09:30', ['time' => '10:00', 'disabled' => true], '10:30',
'11:00', ['time' => '11:30', 'disabled' => true], '14:00', '14:30',
]" value="10:30" />
Clocks
The clock follows the locale: 9:30 AM in en-US, 09:30 in de. hour12 sets it either way. Whatever it shows, it submits 09:30.
Show code Hide code
<div class="flex flex-wrap gap-6">
<x-widget.time-picker name="t_us" label="en-US" locale="en-US" value="09:30" class="max-w-48" />
<x-widget.time-picker name="t_de" label="de" locale="de" value="09:30" class="max-w-48" />
<x-widget.time-picker name="t_24" label="hour12 false" :hour12="false" value="21:15" class="max-w-48" />
</div>
States
The error clears the moment a new time is picked. Required stops an empty submit with "Choose a time." in the same place.
Pick a time inside opening hours.
Show code Hide code
<div class="flex flex-wrap gap-6">
<x-widget.time-picker name="t_error" label="With error" error="Pick a time inside opening hours." class="max-w-48" />
<x-widget.time-picker name="t_required" label="Required" required class="max-w-48" />
<x-widget.time-picker name="t_disabled" label="Disabled" value="12:00" disabled class="max-w-48" />
</div>
Props
Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.
<x-widget.time-picker>
| Prop | Default | Description |
|---|---|---|
| name |
null
|
What the time submits as (HH:MM, 24-hour). 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 time: "09:30", "9:30 PM" or a date object. Old input wins after a failed submit; with wire:model and no value, the bound property. |
| variant |
'list'
|
list: a menu of times, step minutes apart. columns: hour, minute (and AM/PM) columns, for any exact minute. segmented: typed straight into the field, hour and minute, with the arrow keys. slots: a grid of times to choose one of, for bookings. native: the browser's own time field, which opens the phone's time picker on a touch screen; it writes the time the browser's way, so hour12 and locale don't apply. |
| placeholder |
null
|
Shown while no time is picked; "Choose a time" by default (list and columns). |
| 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 changed. |
| readonly |
false
|
Shown, and submitted, but it can't be changed: the button opens nothing. With disabled, disabled wins. |
| min |
null
|
The earliest time that can be picked, within one day: "09:00". Defaults to 00:00. |
| max |
null
|
The latest time that can be picked, within one day: "17:30". Defaults to 23:59. |
| step |
null
|
Minutes between the times offered: 15 by default for list and slots, 1 for columns and segmented. |
| hour12 |
null
|
A 12-hour clock with AM and PM (true) or a 24-hour one (false); by default the locale's own. |
| locale |
null
|
The language times are written in (en-US, de, ja…); defaults to the app's. |
| slots |
null
|
slots: the times to offer, as "HH:MM" strings or ['time' => '10:30', 'disabled' => true] for a taken one. Without them, every time from min to max, step minutes apart. |
| required-message |
'Choose a time.'
|
With required: the message when nothing is picked. |
Accessibility
All 7 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 time-picker 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/time-picker/index.blade.php Show
resources/js/widget/time-picker/index.js Show
app/View/Widget/ElementIds.php Show
app/View/Widget/FormField.php Show
app/View/Widget/TimeOfDay.php Show