PhiaUi.Components.TimePicker (phia_ui v0.1.17)

Copy Markdown View Source

Time selection input — styled native <input type="time">.

Wraps the browser's native time 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.

Present in every major UI kit: Mantine TimeInput, Ant Design TimePicker, MUI TimePicker, React Aria TimeField.

Zero JavaScript — uses the native browser time control.

Examples

<%!-- Standalone --%>
<.time_picker id="start" name="start_time" label="Start Time" value="09:00" />

<%!-- With seconds --%>
<.time_picker id="dur" name="duration" with_seconds={true} />

<%!-- Form field integration --%>
<.time_picker
  id="event_time"
  name={@form[:time].name}
  value={@form[:time].value}
  errors={Enum.map(@form[:time].errors, &translate_error/1)}
  label="Event Time"
/>

Summary

Functions

time_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 time value as "HH:MM" or "HH:MM:SS". 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 [].
  • with_seconds (:boolean) - When true, sets step="1" so seconds are shown in the native picker. Defaults to false.
  • 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", "autocomplete", "min", "max"].