Forms

Range

A pair of fields for a range of numbers or amounts, from and to, bound to one array: a price filter, an age bracket. Either end may be left empty. For a range of dates, use the Date picker with range; for one number picked by dragging, the Slider.

Price
Price: {"from":null,"to":null}
Blade

A fieldset titled "Price" with two number inputs side by side, labelled "From" and "To". Typing 10 and 50 sets $price to ['from' => '10', 'to' => '50']. When "From" is greater than "To", both inputs turn red and "The minimum is greater than the maximum." shows under them, until the numbers are put right.

Amounts #

Two money inputs with the currency symbol, sending the amounts as decimals: ['from' => '1500.00', 'to' => '4000.00'].

Budget
R$
R$
Budget: {"from":null,"to":null}
Blade

In a classic form #

Outside Livewire the inputs are named age[from] and age[to], and value fills them. to:max reaches only the second input.

Age
Blade

Reference

Range

Prop Type Default Description
label string | slot null The title of the fieldset, translated.
description string | slot null Text under the title.
type string number number for number inputs, money for money inputs.
fromLabel, toLabel string From, To The labels of the two inputs, translated.
name string null The base name outside Livewire: the inputs are <name>[from] and <name>[to].
value array null ['from' => ..., 'to' => ...], without wire:model or x-model.
size string md xs, sm, md, lg, xl, 2xl or 3xl.

wire:model and x-model bind an array with from and to keys: each input gets the binding with its key (price.from, price.to), modifiers included. Other attributes (min, max, step, placeholder, currency...) go to both inputs.

tk:range

Prefixes

Prefix Goes to
from: The first input (from:placeholder="0").
to: The second input.

Customization

Classes and the id go to the <fieldset>. The inputs take prefixes (listed in the Reference above).

blade

Accessibility

A <fieldset> whose <legend> is the label, with two labelled inputs, so screen readers announce "Price, From" and "Price, To". The message about the order of the numbers has role="alert", and both inputs get aria-invalid while it shows.

Behavior notes

  • The check that "From" is not greater than "To" runs in the browser for type="number" only; with type="money" it is left to your validation.
  • A validation error on the array (price) shows under both inputs; errors on price.from or price.to show under their input.