LanternUI.Components.Form (LanternUI v0.8.2)

Copy Markdown View Source

Form chrome — label, error, and a Fluxon-compatible input.

<.input name="email" value="" label="Email" help_text="Used for billing." errors={["is required"]} />
<.input name="q" value="" placeholder="Search…">
  <:inner_prefix><.icon name="magnifying-glass" /></:inner_prefix>
</.input>

input/1 mirrors Fluxon's surface: field (a Phoenix.HTML.FormField) or explicit name/value, plus label, sublabel, description, help_text, errors, size, and the four inner/outer_prefix/suffix slots. Styling is LanternUI's shadcn-density look; errors flip the border to danger and get announced via aria-describedby/aria-invalid.

Summary

Functions

Interpolate a changeset error tuple into a message string for host-owned forms.

Functions

error(assigns)

Attributes

  • class (:any) - Extra classes merged onto the root element. Defaults to nil.
  • Global attributes are accepted. Arbitrary HTML/phx-* attributes passed through.

Slots

  • inner_block (required) - Error message text.

input(assigns)

Attributes

  • id (:any) - Element id; derived from field when omitted. Defaults to nil.
  • label (:string) - Primary label above the control. Defaults to nil.
  • sublabel (:string) - Secondary label line under the primary label. Defaults to nil.
  • help_text (:string) - Trailing help line under the field when no errors. Defaults to nil.
  • description (:string) - Helper text under the label stack. Defaults to nil.
  • class (:any) - Extra classes merged onto the root element. Defaults to nil.
  • size (:string) - Control density / type scale. Defaults to "md". Must be one of "xs", "sm", "md", "lg", or "xl".
  • disabled (:boolean) - Render disabled and non-interactive. Defaults to false.
  • field (Phoenix.HTML.FormField) - Form field; derives id, name, value, and errors. Defaults to nil.
  • value (:any) - Current input value. Defaults to nil.
  • name (:any) - Form input name; derived from field when omitted. Defaults to nil.
  • errors (:list) - Validation messages; derived from field when used. Defaults to [].
  • type (:string) - HTML input type (text, email, hidden, …). Defaults to "text".
  • Global attributes are accepted. Arbitrary HTML/phx-* attributes passed through. Supports all globals plus: ["placeholder", "autocomplete", "autofocus", "readonly", "required", "min", "max", "step", "minlength", "maxlength", "pattern", "inputmode", "list", "form"].

Slots

  • inner_prefix - Affix inside the control, before the input.
  • outer_prefix - Affix outside the control, before the wrap.
  • inner_suffix - Affix inside the control, after the input.
  • outer_suffix - Affix outside the control, after the wrap.

label(assigns)

Attributes

  • for (:string) - id of the labeled control. Defaults to nil.
  • class (:any) - Extra classes merged onto the root element. Defaults to nil.
  • sublabel (:string) - Secondary line under the primary label text. Defaults to nil.
  • description (:string) - Helper line under the label (Fluxon parity). Defaults to nil.
  • Global attributes are accepted. Arbitrary HTML/phx-* attributes passed through.

Slots

  • inner_block (required) - Primary label text.

translate_error(msg)

Interpolate a changeset error tuple into a message string for host-owned forms.