Form inputs

Range entry

<forma-range-entry>

Direct lower/upper endpoint entry; graphical dual-thumb behavior is an optional application enhancement.

Authoring tag
<forma-range-entry>
Category
Form inputs
Behavior owner
Native HTML
Canonical source
patterns/range-entry.html

Purpose

Range entry collects a lower and an upper bound as two labelled native number inputs inside a fieldset, with a separator between them and a status line that restates the range. Typed entry is always available, so no dragging is required. Checking that the minimum does not exceed the maximum, writing the status text and any graphical dual-thumb slider are application behavior; Forma supplies the layout.

Use when

  • Users set both ends of a numeric range, such as a price band, response-time window or age range.
  • Exact endpoint values matter.
  • A graphical range control would otherwise be the only way in.

Avoid when

Behavior to know

  • Two independent native number inputs, each with its own visible label.
  • The fieldset legend names the whole range for assistive technology.
  • The status line is a polite live region the application updates with the interpreted range or an error.

Basic example

The smallest correct markup: the canonical pattern from patterns/range-entry.html inside its public tag. Copy this first, then adapt labels, names and state.

Canonical

Minimal range entry

Rendered from the canonical pattern file.

Acceptable response-time range

Enter both endpoints. A graphical range slider may be added by Limen as an enhancement, but direct entry remains available.

500 to 1500 milliseconds

HTML · Minimal range entry Raw HTML for HTML · Minimal range entry
<forma-range-entry class="forma-component-tag">
<fieldset class="forma-range-entry">
  <legend class="forma-range-entry__legend">Acceptable response-time range</legend>
  <p class="forma-field__description">Enter both endpoints. A graphical range slider may be added by Limen as an enhancement, but direct entry remains available.</p>

  <div class="forma-range-entry__inputs">
    <label>
      <span>Minimum</span>
      <input type="number" name="response-time-min" min="0" max="5000" step="50" value="500" inputmode="decimal">
    </label>
    <span class="forma-range-entry__separator" aria-hidden="true">to</span>
    <label>
      <span>Maximum</span>
      <input type="number" name="response-time-max" min="0" max="5000" step="50" value="1500" inputmode="decimal">
    </label>
  </div>

  <p class="forma-range-entry__status" data-forma-state="valid" aria-live="polite">500 to 1500 milliseconds</p>
</fieldset>
</forma-range-entry>

Click or tap the code once to select all of it, then copy.

Examples

Scenario

Price filter

A price band for filtering products, with the currency in the legend and whole-currency steps. Both endpoints are optional, and the status restates what will be applied.

Price (USD)

$50 and above

HTML · Price filter Raw HTML for HTML · Price filter
<forma-range-entry class="forma-component-tag">
  <fieldset class="forma-range-entry">
    <legend class="forma-range-entry__legend">Price (USD)</legend>
    <div class="forma-range-entry__inputs">
      <label>
        <span>Lowest</span>
        <input type="number" name="price-min" min="0" max="10000" step="1" value="50" inputmode="numeric">
      </label>
      <span class="forma-range-entry__separator" aria-hidden="true">to</span>
      <label>
        <span>Highest</span>
        <input type="number" name="price-max" min="0" max="10000" step="1" inputmode="numeric">
      </label>
    </div>
    <p class="forma-range-entry__status" data-forma-state="valid" aria-live="polite">$50 and above</p>
  </fieldset>
</forma-range-entry>

Click or tap the code once to select all of it, then copy.

Scenario

Minimum above maximum

The application found the minimum larger than the maximum. The maximum input is marked invalid and the status line switches to an error that names the fix, with the invalid state recorded in data-forma-state for the application.

Acceptable latency (milliseconds)

The maximum (800) must be at least the minimum (1200).

HTML · Minimum above maximum Raw HTML for HTML · Minimum above maximum
<forma-range-entry class="forma-component-tag">
  <fieldset class="forma-range-entry">
    <legend class="forma-range-entry__legend">Acceptable latency (milliseconds)</legend>
    <div class="forma-range-entry__inputs">
      <label>
        <span>Minimum</span>
        <input type="number" name="latency-min" min="0" max="5000" step="50" value="1200" inputmode="numeric">
      </label>
      <span class="forma-range-entry__separator" aria-hidden="true">to</span>
      <label>
        <span>Maximum</span>
        <input type="number" name="latency-max" min="0" max="5000" step="50" value="800" inputmode="numeric" aria-invalid="true" aria-describedby="range-entry-reversed-status">
      </label>
    </div>
    <p class="forma-range-entry__status" id="range-entry-reversed-status" data-forma-state="invalid" aria-live="polite">The maximum (800) must be at least the minimum (1200).</p>
  </fieldset>
</forma-range-entry>

Click or tap the code once to select all of it, then copy.

Mobile

Each mobile example renders in its own document inside a real narrow viewport, so Forma's media and container queries run exactly as they would on a phone. Choose a width to compare.

Mobile example

Mobile age range

An audience age range at phone width. The endpoints stack vertically so each input keeps a usable width.

Viewport width

Frames narrower than the selected width show the component at the width available.

What changes at narrow widths

  • At 44rem (704px) and below the inputs grid becomes one column: Minimum, the separator word, then Maximum.
  • Above that width the two inputs sit side by side (each at least 7rem) within a 30rem maximum width.
  • Each input keeps a 44px minimum height and inputmode=numeric shows a digit keypad.
  • The status line wraps under the inputs; nothing scrolls horizontally.
HTML · Mobile age range Raw HTML for HTML · Mobile age range
<forma-range-entry class="forma-component-tag">
  <fieldset class="forma-range-entry">
    <legend class="forma-range-entry__legend">Audience age</legend>
    <div class="forma-range-entry__inputs">
      <label>
        <span>From age</span>
        <input type="number" name="age-min" min="13" max="100" step="1" value="18" inputmode="numeric">
      </label>
      <span class="forma-range-entry__separator" aria-hidden="true">to</span>
      <label>
        <span>To age</span>
        <input type="number" name="age-max" min="13" max="100" step="1" value="34" inputmode="numeric">
      </label>
    </div>
    <p class="forma-range-entry__status" data-forma-state="valid" aria-live="polite">Ages 18 to 34</p>
  </fieldset>
</forma-range-entry>

Click or tap the code once to select all of it, then copy.

Baseline

Mobile · 320px

The canonical pattern in a true 320px viewport, the minimum width every Forma component must support without page-level horizontal scrolling.

Viewport width

Frames narrower than the selected width show the component at the width available.

API and configuration

Forma components have no JavaScript API. Their public contract is the markup: native elements and attributes you write, and the CSS hooks below. The CSS hook table is generated from the built stylesheet, so it always matches the shipped implementation.

Native and ARIA attributes
AttributeOnValuesDefaultDescription
typeinputnumber—Both endpoints are native number inputs.
mininputnumber—Lowest allowed value for each endpoint.
maxinputnumber—Highest allowed value for each endpoint. Native constraints do not relate the two inputs to each other.
stepinputnumber1Allowed increment.
valueinputnumberemptyInitial endpoint value.
nameinputstring—Separate field names for the lower and upper bound.
inputmodeinputnumeric | decimalfrom typeKeypad hint for touch devices.
aria-live.forma-range-entry__statuspolite—Announces the application's updated range or error text.
aria-hidden.forma-range-entry__separatortrue—The visual "to" is not read; each input has its own label.
aria-invalidinputtrueabsentSet by the application on the endpoint that needs correcting.
aria-describedbyinputid of the status—Links the error text in the status line to the invalid endpoint.
CSS hooks (derived from dist/all.css)
HookKindValues or defaultDescription
.forma-range-entryBlock class—Root fieldset with margin, padding and border removed.
.forma-range-entry__inputsElement class—Three-column grid (endpoint, separator, endpoint) up to 30rem wide; one column at 44rem and below.
.forma-range-entry__legendElement class—Legend naming the range (1rem, bold).
.forma-range-entry__separatorElement class—Visual separator word, bottom-aligned with the inputs.
.forma-range-entry__statusElement class—Status line restating the range or reporting an error (0.8125rem, weight 650).
[data-forma-state]Attribute hook—Application-owned marker on the status line (the pattern uses valid; examples use invalid). Forma does not currently style it, so the status text itself must carry the meaning.
Keyboard interaction
KeysResult
Tab / Shift+TabMoves between the minimum and maximum inputs.
ArrowUp / ArrowDownSteps the focused endpoint within its own min and max (native).
Events
EventDescription
input / changeNative events from each endpoint; cross-field validation and status updates are application code.

Form behavior

Each endpoint submits separately under its own name and validates its own min, max and step. The relationship between endpoints is not enforced natively.

States

Range entry states
StateHow it is expressedPresentation
Validapplication status text; data-forma-state="valid"Status restates the interpreted range.
Open-endedone endpoint emptyStatus explains the open bound, for example "$50 and above".
Invalidaria-invalid on an endpoint plus error text in the status; data-forma-state="invalid"Status names the fix. Forma does not restyle the status or input, so the text carries the error.
Focus:focus-visibleFoundation focus ring on the focused endpoint.

Accessibility

Forma provides

  • A fieldset and legend group the endpoints; each endpoint has its own visible label.
  • Typed entry is always available, so no drag interaction is needed.
  • The separator is hidden from assistive technology.

Your application supplies

  • Validate that the minimum does not exceed the maximum and describe errors in text in the status line.
  • Keep the status line's live text short and update it only after the user commits a value.
  • If Limen adds a dual-thumb slider, keep these inputs available and synchronized, and give each thumb its own label.

Responsive behavior

  • Side by side, each endpoint column is at least 7rem and the group is at most 30rem wide.
  • At 44rem (704px) and below the endpoints stack in one column and the separator loses its padding.
  • Labels and status text wrap; the component never forces horizontal scrolling.

Motion

  • No animation: range entry has no transitions. Status text changes immediately.

Usage guidance

Do

  • Put the unit in the legend so both endpoint labels stay short.
  • Restate the resulting range in words in the status line.

Avoid

  • Swapping reversed endpoints silently; tell the user.
  • Offering only a dual-thumb slider without these direct inputs.

Verification specimens

Generated fault-injection specimens expose content, spacing, color-cue, and reduced-effective-contrast risks. They screen presentation robustness as engineering screens without claiming human-subject validation.