PUI. Components
(pui v1.0.0)
Copy Markdown
Summary
Functions
badge(assigns)
deprecated
Renders form field error messages.
progress(assigns)
deprecated
Translates a form error tuple into a human-readable string.
Functions
This function is deprecated. Use PUI.Badge.badge/1 instead..
Attributes
class(:string) - Defaults to"".variant(:string) - Defaults to"default". Must be one of"default","secondary","destructive", or"outline".
Slots
inner_block
Renders form field error messages.
Displays validation errors below form inputs. Renders nothing when errors is empty.
Each error paragraph is marked with role="alert" and aria-live="polite" so screen
readers announce new errors as they appear. A deterministic id is generated from
the id attribute (defaulting to "field-error") so callers can wire the input's
aria-errormessage to it.
Examples
<.field_error errors={["can't be blank"]} />
<.field_error id="user_email-error" errors={["must be at least 3 characters", "is invalid"]} />
<.field_error errors={[]} />Attributes
id(:string) - id prefix for each error paragraph; suffixed with the error index. Defaults to"field-error".errors(:list) - Defaults to[].
This function is deprecated. Use PUI.Progress.progress/1 instead..
Attributes
min(:float) - Defaults to0.0.max(:float) - Defaults to100.0.value(:float) - Defaults to0.0.label(:string) - accessible label for the progressbar. Defaults tonil.aria_labelledby(:string) - id of an element labelling the progressbar. Defaults tonil.value_text(:string) - human-readable value text announced by screen readers. Defaults tonil.class(:string) - Defaults to"".
Translates a form error tuple into a human-readable string.
Error tuples from changesets have the form {msg, opts} where msg may contain
interpolation placeholders like %{count}.
Examples
iex> PUI.Components.translate_error({"can't be blank", []})
"can't be blank"
iex> PUI.Components.translate_error({"should be at least %{count} character(s)", [count: 3]})
"should be at least 3 character(s)"