v0.0.2
Demos (demo panel, opens in a new tab)

Date range

Lets users pick a start and an end day in one field, from a calendar.

zb:date-range zubazar/ui-pro

PRO

Needs a JavaScript library registration: see Setup.

This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →

Classic form

Classic form: view
BLADE

start-name and end-name name two hidden fields; the form sends the range in them as Y-m-d.

blade
<div x-data="{ range: null }" x-on:date-range-picked="range = $event.detail" class="space-y-2">
    <zb:date-range label="Report period" start-name="from" end-name="until" hint="Orders between these days are listed." />
    <p class="text-sm text-dim" x-text="range ? 'Will send: from=' + range.start + ', until=' + range.end : 'Pick a start and an end day.'"></p>
</div>
PropValues
start-name, end-nameThe hidden fields' names
start, endThe range chosen at first (Y-m-d)

With Livewire

BLADE

start-property and end-property are the component properties the selection is written to; give the initial values from the same properties.

blade
{{-- In the Livewire component: public ?string $from = null; public ?string $until = null; --}}
<zb:date-range
    label="Order date"
    start-property="from"
    end-property="until"
    :start="$from"
    :end="$until"
/>
PropValues
start-property, end-propertyThe properties written to
date-range-pickedThe event when the range is complete: { start, end }

Closed days and format

Closed days and format: view
BLADE

min-date="today" blocks past days and :disabled-ranges blocks given days or ranges; format changes the format shown in the field.

blade
<zb:date-range
    label="Campaign period"
    start-name="campaign_start"
    end-name="campaign_end"
    min-date="today"
    :disabled-ranges="[['from' => '2026-12-24', 'to' => '2026-12-26'], '2026-12-31']"
    format="j M Y"
/>
PropValues
min-date'today' | Y-m-d
disabled-rangesDates or from/to ranges
formatA flatpickr format

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
label—nullThe label above the field
hint—nullThe help text below; an error replaces it
placeholder—Choose a date rangeThe text in the empty field
start, end—nullThe range chosen at first (Y-m-d)
startProperty, endProperty—nullLivewire: the properties the range is written to
startName, endName—nullA classic form: the hidden fields' names; old() values come back after a failed validation
minDate—nullThe first day that can be chosen: 'today' or Y-m-d
disabledRanges—[]Days that cannot be chosen: dates or ['from' => …, 'to' => …]
format—nullHow the range reads in the field (flatpickr); by default d.m.Y or m/d/Y by the page's language
input-class—nullClasses of the field itself; class places the whole field

Slots: class, style, x-show and wire:key go on the element around the whole field (with the label and the message); other attributes such as required, disabled, aria-* and events go on the field. x-on:date-range-picked can also be written on zb:date-range itself.

Installation

Install flatpickr and register it in resources/js/app.js; the calendar opens in the page's language.

js
// npm install flatpickr
// resources/js/app.js
document.addEventListener('livewire:init', () => {
    const { lazyLibrary, registerDateRangePicker } = window.ZubazarUI.pro;

    registerDateRangePicker(window.Alpine, lazyLibrary(async () => {
        const turkish = document.documentElement.lang.startsWith('tr');
        const [{ default: flatpickr }, locale] = await Promise.all([
            import('flatpickr'),
            turkish ? import('flatpickr/dist/l10n/tr.js') : Promise.resolve(null),
            import('flatpickr/dist/flatpickr.min.css'),
        ]);
        if (locale) flatpickr.localize(locale.Turkish);

        return flatpickr;
    }));
});

Developer notes

Events, hooks and details
  • The calendar sits in wire:ignore; a range the server writes to the properties (e.g. a reset after saving) reaches it too, and the label, hint and error refresh with Livewire updates.
  • A validation error on either property shows below the field; your aria-describedby value is merged with the message's id.

Events

EventdetailDescription
date-range-picked{ start, end }Sent from the field (the original input, which stays hidden in the page) when both days are picked; it bubbles. Dates are Y-m-d strings. Also sent when the range is set from code or by the server; a cleared range gives empty strings.
Zubazar UI · ZubazarDesigned for people.