EzAuth.UI.Core.Errors (EzAuth v0.1.0)

Copy Markdown View Source

Error-rendering components.

message/1 renders errors for a single form field. summary/1 renders a flow-level list for messages that don't belong to any single field.

Summary

Functions

Renders errors for a form field.

Renders a flow-level error summary for messages that don't belong to a single field.

Functions

message(assigns)

Renders errors for a form field.

Pass either a form field or an inner_block slot with a message. Field errors only surface after the user has interacted with the field.

Options

  • :field - form field whose visible errors should be rendered.
  • :id - unique id for the error message. Defaults to "<field-id>-error" when :field is set.

Styling

  • [data-part="error"] - error message.

Examples

<EzAuth.UI.Core.Errors.message field={@form[:email]} />

<EzAuth.UI.Core.Errors.message id="custom-error">
  Something went wrong
</EzAuth.UI.Core.Errors.message>

Attributes

Slots

  • inner_block

summary(assigns)

Renders a flow-level error summary for messages that don't belong to a single field.

Announced as an alert and takes focus on mount so keyboard users land on the summary after a failed submit.

Options

  • :errors - list of error strings to display.

Styling

  • [data-part="error-summary"] - error summary container.
  • [data-part="error-summary-list"] - error list.
  • [data-part="error-summary-item"] - each error item.

Examples

<EzAuth.UI.Core.Errors.summary errors={["Please complete all required fields"]} />

Attributes

  • errors (:list) - Defaults to [].
  • Global attributes are accepted.