LineOne's date pickers (flatpickr's calendar in LineOne's skin): one date, several dates or a range, with limits, disabled days, a custom text format, a time row, and a calendar that pops under the input or stays inline.
<.date_picker field={@form[:due_on]} placeholder="Choose date..." />
<.date_picker name="trip" mode="range" value={{~D[2026-10-10], ~D[2026-10-20]}} />
<.date_picker name="days" mode="multiple" disabled_weekdays={[0, 6]} week_start={1} />
<.datetime_picker field={@form[:starts_at]} min_time="16:00" max_time="22:00" />
<.date_picker name="due" display_format="M j, Y" show_icon={false} placeholder="Due date" />The input shows the date in display_format (flatpickr tokens: Y-m-d, F j, Y, H:i...);
the form gets ISO text through hidden inputs named like the field: 2026-10-23 (one date),
2026-10-23 16:30 (date and time), and name[] per date for multiple and range (with an
empty name[] first so an empty choice still reaches the server). A pick fires a bubbling
input event, so phx-change runs; the server re-rendering the same value changes nothing,
a different value replaces the one in the browser.
The calendar is an overlay: LineaUI.open/close/toggle("id") work on it, and
date_picker_clear/1 empties it.
Summary
Functions
Renders a date input with its calendar.
A %JS{} that empties the picker with id, for a clear button.
Renders a date and time input: the calendar with flatpickr's hour and minute row.
Functions
Renders a date input with its calendar.
<.date_picker id="due" name="due" label="Due" min={Date.utc_today()} />
<.date_picker id="when" name="when" placeholder="Choose date">
<:trailing>
<.button phx-click={LineaUI.toggle("when")}>…</.button>
<.button phx-click={date_picker_clear("when")}>×</.button>
</:trailing>
</.date_picker>Events: on_change is pushed with %{"id" => id, "value" => value} after each pick, where
value is the ISO text (or a list of them for multiple and range), to target or to the
LiveView/LiveComponent the picker is in.
Attributes
id(:string) - Defaults to the field id, or a generated one.name(:string) - Defaults to the field name.value(:any) - ADate, ISO text, a list of them,{from, to}or aDate.Range.field(Phoenix.HTML.FormField) - Defaults tonil.label(:string) - Defaults tonil.help(:string) - Defaults tonil.errors(:list) - Defaults to[].placeholder(:string) - Defaults tonil.mode(:string) - Defaults to"single". Must be one of"single","multiple", or"range".min(:any) - The first day that can be picked (Dateor ISO text). Defaults tonil.max(:any) - The last day that can be picked. Defaults tonil.disabled_dates(:list) - Days that cannot be picked. Defaults to[].disabled_weekdays(:list) - Weekdays that cannot be picked, 0 = Sunday. Defaults to[].week_start(:integer) - The first column of the calendar, 0 = Sunday. Defaults to0.display_format(:string) - The text of the input in flatpickr tokens;Y-m-dby default.M j, YreadsOct 23, 2026,D, M jreadsFri, Oct 23,F j, YreadsOctober 23, 2026. Only the shown text changes: the form still gets ISO. Defaults tonil.months(:list) - The twelve month names, for another language. Defaults tonil.weekdays(:list) - The seven weekday names from Sunday; the calendar shows their first three letters. Defaults tonil.today(:any) - The day marked as today; the server's UTC day by default. Defaults tonil.inline(:boolean) - The calendar always shows, under the input. Defaults tofalse.show_icon(:boolean) - The calendar icon inside the input;falseleaves a bare input (and drops the left padding). Defaults totrue.disabled(:boolean) - Defaults tofalse.on_change(:string) - Defaults tonil.target(:any) - Defaults tonil.class(:any) - Classes of the input. Defaults tonil.- Global attributes are accepted.
Slots
icon- Replaces the calendar icon.trailing- Buttons joined to the right of the input (LineOne's External Elements); the icon is then left out.
@spec date_picker_clear(Phoenix.LiveView.JS.t(), String.t()) :: Phoenix.LiveView.JS.t()
A %JS{} that empties the picker with id, for a clear button.
<.button phx-click={date_picker_clear("when")}>Clear</.button>
Renders a date and time input: the calendar with flatpickr's hour and minute row.
<.datetime_picker name="meeting" placeholder="Choose datetime..." min_time="16:00" max_time="22:00" />Takes every attr of date_picker/1 (in single mode) and the time attrs below. The form
gets 2026-10-23 16:30.
Attributes
id(:string) - Defaults to the field id, or a generated one.name(:string) - Defaults to the field name.value(:any) - ANaiveDateTime,DateTimeor"2026-10-23 16:30".field(Phoenix.HTML.FormField) - Defaults tonil.label(:string) - Defaults tonil.help(:string) - Defaults tonil.errors(:list) - Defaults to[].placeholder(:string) - Defaults tonil.min(:any) - Defaults tonil.max(:any) - Defaults tonil.disabled_dates(:list) - Defaults to[].disabled_weekdays(:list) - Defaults to[].week_start(:integer) - Defaults to0.display_format(:string) -Y-m-d H:iby default. Defaults tonil.months(:list) - Defaults tonil.weekdays(:list) - Defaults tonil.today(:any) - Defaults tonil.inline(:boolean) - Defaults tofalse.show_icon(:boolean) - Defaults totrue.time_24hr(:boolean) - Hours 0-23 instead of 1-12 with AM/PM. Defaults tofalse.min_time(:string) - The earliest time,"HH:MM". Defaults tonil.max_time(:string) - The latest time,"HH:MM". Defaults tonil.minute_step(:integer) - Defaults to5.hour_step(:integer) - Defaults to1.default_hour(:integer) - The hour a first pick starts at. Defaults to12.disabled(:boolean) - Defaults tofalse.on_change(:string) - Defaults tonil.target(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
icontrailing