Numeric stepper input component with optional prefix/suffix and form integration.
Renders a number input flanked by decrement (−) and increment (+) buttons.
The buttons use type="button" so they never trigger form submission — the
parent form controls submit behaviour. The input itself is a native
<input type="number"> which preserves browser built-in keyboard behaviour
(arrow keys, scroll wheel) and numeric validation.
Basic usage
<.number_input name="quantity" value={@qty} />With constraints
<.number_input name="quantity" value={@qty} min={0} max={100} step={1} />With prefix and suffix
<.number_input name="price" value={@price} prefix="$" suffix="USD" />Form-integrated usage
<.form_number_input field={@form[:price]} label="Price" prefix="$" />Disabled / read-only
<.number_input name="qty" value={0} disabled={true} />
<.number_input name="qty" value={42} readonly={true} />
Summary
Functions
Renders a form-integrated number input with label and error messages.
Renders a stepper-style number input with optional prefix/suffix decorators.
Functions
Renders a form-integrated number input with label and error messages.
Wraps number_input/1 with a <label> (when :label is given) and error
<p> elements sourced from field.errors. Error messages are interpolated
using the same translate_error/1 helper as the rest of the PhiaUI form
components.
Examples
<.form_number_input field={@form[:quantity]} label="Quantity" />
<.form_number_input field={@form[:price]} label="Price" prefix="$" />
<.form_number_input
field={@form[:amount]}
label="Amount"
min={0}
max={9999}
step={0.01}
/>Attributes
field(Phoenix.HTML.FormField) (required) - APhoenix.HTML.FormFieldstruct (typically@form[:field_name]). Providesid,name,value, anderrorsautomatically.label(:string) - Label text rendered above the input. Omit to suppress the<label>element. Defaults tonil.prefix(:string) - Optional prefix text (e.g."$"). Defaults tonil.suffix(:string) - Optional suffix text (e.g."USD"). Defaults tonil.class(:string) - Additional classes merged into the underlying<input>. Defaults tonil.min(:any) - Minimum allowed value. Defaults tonil.max(:any) - Maximum allowed value. Defaults tonil.step(:any) - Step amount. Defaults to1. Defaults to1.placeholder(:string) - Placeholder text. Defaults tonil.disabled(:boolean) - Disables the input. Defaults tofalse.readonly(:boolean) - Makes the input read-only. Defaults tofalse.
Renders a stepper-style number input with optional prefix/suffix decorators.
The layout is: [−] [input] [+] — decrement button, the numeric input,
and an increment button. Both buttons have type="button" and carry
accessible aria-label attributes ("Decrease" / "Increase").
ARIA attributes aria-valuemin, aria-valuemax, and aria-valuenow are
set on the input when the corresponding props are provided, making the range
semantics available to assistive technology.
Examples
<%!-- Basic --%>
<.number_input name="qty" value={@qty} />
<%!-- With constraints --%>
<.number_input name="qty" value={@qty} min={0} max={99} step={1} />
<%!-- With currency prefix --%>
<.number_input name="price" value={@price} prefix="$" />
<%!-- Disabled state --%>
<.number_input name="qty" value={0} disabled={true} />Attributes
id(:string) - HTML id attribute for the underlying<input>element. Defaults tonil.name(:string) - HTML name attribute forwarded to<input>. Required for form submission. Defaults tonil.value(:any) - Current numeric value. Passed as thevalueattribute of the<input>. Defaults tonil.min(:any) - Minimum allowed value. Maps to the nativeminattribute. Defaults tonil.max(:any) - Maximum allowed value. Maps to the nativemaxattribute. Defaults tonil.step(:any) - Step increment/decrement amount. Defaults to1. Defaults to1.placeholder(:string) - Placeholder text shown when the input is empty. Defaults tonil.disabled(:boolean) - Disables the input and stepper buttons. Defaults tofalse.readonly(:boolean) - Makes the input read-only. Defaults tofalse.prefix(:string) - Optional text shown to the left inside the input (e.g."$"). Defaults tonil.suffix(:string) - Optional text shown to the right inside the input (e.g."USD"). Defaults tonil.class(:string) - Additional Tailwind classes merged into the<input>element viacn/1. Defaults tonil.