PhiaUi.Components.DateField (phia_ui v0.1.17)

Copy Markdown View Source

Form-aware standalone date input component for Phoenix LiveView.

date_field/1 renders a styled <input type="date"> — label, optional description, date input, and inline validation errors. It is a lightweight alternative to date_picker/1 (which opens a popover calendar); date_field/1 uses the native browser date picker with no JavaScript.

Usage

<.date_field id="start" name="start_date" label="Start date" />

<.date_field
  id="due"
  name="due_date"
  label="Due date"
  description="Must be in the future"
  min={Date.to_iso8601(Date.utc_today())}
/>

<.date_field
  id="birth"
  name="birth_date"
  value="1990-01-15"
  label="Date of birth"
  max="2010-12-31"
  errors={["is required"]}
/>

Error display

Pass a list of pre-translated error strings via :errors. For form-aware integration, use phia_input/1 with type="date" or date_picker/1.

Global attributes

The following HTML attributes are forwarded to the <input> element via the :global attribute: required, placeholder, phx-debounce, autocomplete, min, max.

Summary

Functions

date_field(assigns)

Attributes

  • id (:string) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • value (:string) - Defaults to nil.
  • label (:string) - Defaults to nil.
  • description (:string) - Defaults to nil.
  • errors (:list) - Defaults to [].
  • disabled (:boolean) - Defaults to false.
  • size (:atom) - Defaults to :default. Must be one of :sm, :default, or :lg.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["required", "placeholder", "phx-debounce", "autocomplete", "min", "max"].