A calendar date picker.
A port of the Pines date picker.
<.date_picker name="due_on" label="Due date" value={@due_on} />The calendar grid is built on the server
Pines builds the month grid in Alpine. This port computes it in Elixir instead and renders
real <button> elements, which buys three things: the dates are in the DOM for tests and
crawlers, Date handles leap years and month lengths rather than hand-rolled JavaScript,
and keyboard navigation works on ordinary focusable elements.
Alpine only handles opening the panel and moving between months, and month changes are
driven through phx-click when you pass on_navigate, so a server-rendered calendar
stays authoritative.
Summary
Forms
Renders a date picker.
Forms
Renders a date picker.
Accessibility
The calendar is a grid of gridcell buttons inside a labelled dialog. The selected day
carries aria-selected, today carries aria-current="date", and out-of-range days are
genuinely disabled rather than merely dimmed.
Attributes
id(:string) - Defaults tonil.name(:string) (required)value(:any) - ADate, an ISO 8601 string, or nil. Defaults tonil.label(:string) - Defaults tonil.placeholder(:string) - Defaults to"Select a date".hint(:string) - Defaults tonil.error(:string) - Defaults tonil.disabled(:boolean) - Defaults tofalse.required(:boolean) - Defaults tofalse.min(:any) - Earliest selectable date. Defaults tonil.max(:any) - Latest selectable date. Defaults tonil.month(:any) - Month to display. Defaults to the value's month, or today. Defaults tonil.first_day_of_week(:integer) - 1 = Monday (ISO), 7 = Sunday. Defaults to1.format(:string) -Calendar.strftime/2format for the input. Defaults to"%Y-%m-%d".on_navigate(:string) - Aphx-clickevent fired with amonthvalue when the user changes month. Provide it to render months from the server; omit it and the picker shows only the initial month's grid, which suits a simple form.Defaults to
nil.class(:string) - Defaults tonil.container_class(:string) - Defaults tonil.Global attributes are accepted.