PhiaUi.Components.MonthPicker (phia_ui v0.1.17)

Copy Markdown View Source

Month selection input — styled native <input type="month">.

Wraps the browser's native month picker with PhiaUI's input styling (borders, focus ring, size variants, error state). Supports standalone use or Phoenix form field integration with changeset error display.

Value format: "YYYY-MM" (e.g. "2026-03").

Zero JavaScript — uses the native browser month control.

Examples

<%!-- Standalone --%>
<.month_picker id="period" name="billing_month" label="Billing Month" value="2026-03" />

<%!-- With min/max constraints --%>
<.month_picker id="period" name="billing_month" min="2024-01" max="2026-12" />

<%!-- Form field integration --%>
<.month_picker
  id="subscription_month"
  name={@form[:month].name}
  value={@form[:month].value}
  errors={Enum.map(@form[:month].errors, &translate_error/1)}
  label="Subscription Month"
/>

Summary

Functions

month_picker(assigns)

Attributes

  • id (:string) - HTML id for the input and label for link. Defaults to nil.
  • name (:string) - HTML name for form submission. Defaults to nil.
  • value (:string) - Current month value as "YYYY-MM" (e.g. "2026-03"). Defaults to nil.
  • label (:string) - Label text rendered above the input. Defaults to nil.
  • description (:string) - Helper text rendered below the label. Defaults to nil.
  • errors (:list) - List of error message strings. Defaults to [].
  • disabled (:boolean) - Disables the input. Defaults to false.
  • size (:atom) - Input height/padding: :sm (h-8), :default (h-10), :lg (h-12). Defaults to :default. Must be one of :sm, :default, or :lg.
  • class (:string) - Additional CSS classes merged onto the input. Defaults to nil.
  • Global attributes are accepted. HTML attributes forwarded to the <input> element. Supports all globals plus: ["required", "placeholder", "phx-debounce", "min", "max"].