Number Input
Numeric field with stepper buttons, modifier-key step sizes, snapping, wheel scrubbing, and locale-aware formatting.
Basic
Sizes
Set size to one of xs, sm, md, lg, or xl. Both the field and the stepper buttons scale together.
Label, description, and help text
Combine label, sublabel, description, and help_text for the full form-control surface.
Tell us how this product performed.
Min, max, and step
min and max clamp the value on stepping. step sets the amount added or subtracted on each click or arrow press.
Modifier-augmented stepping
Hold Shift for large_step and Alt for small_step while pressing an arrow key or stepper button. Defaults are step * 10 and step / 10.
Snap to step
With snap_on_step, increment and decrement round to the nearest multiple of step, even when the current value is off-grid.
Without stepper buttons
Set controls="none" to drop the flanking buttons. Keyboard stepping (arrow keys, PageUp, PageDown, Home, End) still works.
Wheel scrubbing
allow_wheel_scrub lets the user adjust the value by scrolling the mouse wheel while holding Alt on a focused field. The modifier prevents accidental changes from page scroll.
Currency
Pass a format map with style: "currency" and a currency code. The displayed value is formatted; the form receives the raw number.
Locale-aware formatting
The same value rendered for three locales. Grouping, decimal separator, and currency symbol all follow the locale.
Percent and fraction digits
Use style: "percent" to format a 0..1 value as a percentage, and maximum_fraction_digits to control precision.
Affixes
Four slots compose around the field: :inner_prefix and :inner_suffix sit inside the border and share the focus ring; :outer_prefix and :outer_suffix attach outside, between the field and the stepper buttons.
Outer suffix with action
Drop a .button into :outer_suffix to join a trailing action to the field. Pair with controls="none" so the action sits flush with the field's edge.
Disabled
disabled blocks focus on the field and dims the stepper buttons so they cannot be pressed.
Readonly
readonly keeps the value selectable and the field focusable, but prevents edits. Stepper buttons remain visible but inert.
Pricing calculator
Two number inputs feed a live monthly total. Each tick of the stepper hits the server through phx-change on the surrounding form.
Configure your plan
Pricing updates as you change the inputs.
Cart line item
A compact size="sm" quantity stepper bound to a changeset. Line total recomputes server-side as the quantity changes.
Range filter
Two number inputs collaborating in a filter card. The matching count refreshes whenever either bound changes.
Price
15 of 24 products matchStock-limited stepper
max={@in_stock} reads from socket assigns. The + button clamps and the help text updates as the limit is approached.
Linen tote
Limited release
Validation errors
Bind field to a Phoenix.HTML.FormField and the input renders translated changeset errors automatically once the field has been touched.