Localize.Inputs.Date

Locale-aware date form input components for Phoenix LiveView, built on top of localize, calendrical, and localize_inputs_core. For number and unit-of-measure inputs install localize_number_inputs alongside.

Features

Supported Elixir and OTP versions

Requires Elixir 1.17 and OTP 26 or later.

Installation

def deps do
  [
    {:localize_datetime_inputs, "~> 0.3"},

    # Activate the HEEx components:
    {:phoenix_html, "~> 4.0"},
    {:phoenix_live_view, "~> 1.0"}
  ]
end

Quick start

<.date_input form={@form} field={:dob} />

<.date_input
  form={@form}
  field={:start_date}
  min={~D[2026-01-01]}
  max={~D[2026-12-31]}
  display_format={:long}
/>

<.date_range_input form={@form} field={:vacation} />

<.date_input form={@form} field={:dob} calendar={Calendrical.Hebrew} locale={:"he-IL"} />

Import via import Localize.Inputs.Date.Components in your view module. Parse server-side via Localize.Inputs.Date.Parser.parse_date/2 or Calendrical.Date.parse/2.

A :calendar is always a calendar module, never a CLDR calendar type: one CLDR type can name several calendars — :gregorian names both Calendar.ISO and Calendrical.Gregorian — so calendar={:hebrew} is refused rather than resolved on your behalf.

CSS

@import "../../deps/localize_inputs_core/priv/static/localize_inputs_core.css";
@import "../../deps/localize_datetime_inputs/priv/static/localize_datetime_inputs.css";

The token set is in localize_inputs_core; this package just adds component-specific rules.

JS

import Hooks from "../../deps/localize_datetime_inputs/priv/static/localize_datetime_inputs.js"

new LiveSocket("/live", Socket, {
  hooks: { DatePicker: Hooks.DatePicker, DateRangePicker: Hooks.RangePicker }
})

The date picker grid uses the browser's built-in Intl.DateTimeFormat — no additional JS peer dependencies. Without the hooks loaded the input still works as a plain text field; the server-side parser accepts whatever the user typed on submit.

Documentation

Full documentation is at https://hexdocs.pm/localize_datetime_inputs.

License

Apache-2.0. See LICENSE.md.