Form inputs

Slider

<forma-slider>

Single-value range input with accessible bounds and direct keyboard/pointer control.

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

Purpose

A slider sets one value on a bounded scale by position. Forma uses the native input type="range", so the browser supplies dragging, click-to-position, keyboard stepping, min/max/step snapping, the accessible value and form submission. .forma-slider adds a header for the label, a full-width 44px-tall track area colored with accent-color, visible minimum and maximum labels, and room for a description.

Use when

  • An approximate value on a continuous or finely stepped scale is acceptable, such as volume, opacity or a threshold.
  • Seeing the position relative to the bounds helps the user decide.
  • Every value between min and max is valid.

Avoid when

  • The user needs an exact number: use Numeric stepper or pair the slider with one (the application keeps them in sync).
  • The user sets a lower and an upper bound: use Range entry; a dual-thumb slider is a Limen enhancement.
  • The options are a few named, ordered answers such as agreement levels: use Ordinal scale.
  • Several values share a fixed total: use Allocation.

Behavior to know

  • Native range input: pointer, touch and keyboard all set the value directly.
  • The current value is not displayed by Forma; show it in text when it matters (the application updates that text).
  • Bound labels are visible text and hidden from assistive technology, because the input already exposes min and max.

Basic example

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

Canonical

Minimal slider

Rendered from the canonical pattern file.

HTML · Minimal slider Raw HTML for HTML · Minimal slider
<forma-slider class="forma-component-tag">
<label class="forma-slider">
  <span class="forma-slider__header">
    <span class="forma-slider__label">Volume</span>
  </span>
  <input class="forma-slider__input" type="range" name="volume" min="0" max="100" step="5" value="25">
  <span class="forma-slider__bounds" aria-hidden="true">
    <span>0</span>
    <span>100</span>
  </span>
  <span class="forma-field__description">Adjust the output level.</span>
</label>
</forma-slider>

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

Examples

Scenario

Alert sensitivity with tick marks

A stepped threshold with a datalist connected by list, which shows tick marks in browsers that support it. The bounds use words instead of numbers.

HTML · Alert sensitivity with tick marks Raw HTML for HTML · Alert sensitivity with tick marks
<forma-slider class="forma-component-tag">
  <label class="forma-slider">
    <span class="forma-slider__header">
      <span class="forma-slider__label">Alert sensitivity</span>
    </span>
    <input class="forma-slider__input" type="range" name="alert-sensitivity" min="1" max="5" step="1" value="3" list="slider-named-stops-ticks">
    <span class="forma-slider__bounds" aria-hidden="true">
      <span>Fewer alerts</span>
      <span>More alerts</span>
    </span>
  </label>
  <datalist id="slider-named-stops-ticks">
    <option value="1"></option>
    <option value="2"></option>
    <option value="3"></option>
    <option value="4"></option>
    <option value="5"></option>
  </datalist>
</forma-slider>

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

Scenario

Disabled by policy

A session-timeout slider locked by an administrator. The root is a wrapper with a for/id label so the explanation is linked as a description rather than folded into the accessible name. The input is natively disabled and dimmed.

Set to 30 minutes by your organization's security policy.
HTML · Disabled by policy Raw HTML for HTML · Disabled by policy
<forma-slider class="forma-component-tag">
  <div class="forma-slider">
    <span class="forma-slider__header">
      <label class="forma-slider__label" for="slider-disabled-timeout">Session timeout (minutes)</label>
    </span>
    <input class="forma-slider__input" id="slider-disabled-timeout" type="range" name="session-timeout" min="5" max="120" step="5" value="30" disabled aria-describedby="slider-disabled-timeout-description">
    <span class="forma-slider__bounds" aria-hidden="true">
      <span>5</span>
      <span>120</span>
    </span>
    <span class="forma-field__description" id="slider-disabled-timeout-description">Set to 30 minutes by your organization's security policy.</span>
  </div>
</forma-slider>

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 display brightness

A brightness slider at phone width. The track fills the width and keeps a tall touch area.

Viewport width

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

What changes at narrow widths

  • The input is full width with a 44px minimum height, so the thumb and track are comfortable touch targets.
  • Dragging is direct manipulation owned by the browser; tapping the track moves the thumb to that point.
  • The bounds row wraps if its labels are too long for the width instead of overflowing.
  • Rotating to landscape lengthens the track, which gives finer control.
HTML · Mobile display brightness Raw HTML for HTML · Mobile display brightness
<forma-slider class="forma-component-tag">
  <label class="forma-slider">
    <span class="forma-slider__header">
      <span class="forma-slider__label">Screen brightness</span>
    </span>
    <input class="forma-slider__input" type="range" name="brightness" min="0" max="100" step="1" value="70">
    <span class="forma-slider__bounds" aria-hidden="true">
      <span>0%</span>
      <span>100%</span>
    </span>
  </label>
</forma-slider>

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
typeinputrange—Required. Native range input.
mininputnumber0Lowest value.
maxinputnumber100Highest value.
stepinputnumber | any1Snap increment for pointer and keyboard.
valueinputnumbermidpointInitial value.
nameinputstring—Form field name.
listinputid of a datalist—Optional suggested values; many browsers draw tick marks for them.
disabledinputbooleanabsentRemoves the slider from focus and submission and dims it.
forlabel.forma-slider__labelid of the input—Use with a wrapper root so a description can be linked with aria-describedby instead of joining the accessible name.
aria-describedbyinputid of the description—Links explanatory text.
aria-hidden.forma-slider__boundstrue—Hides the visual bound labels; the input already exposes its min and max.
CSS hooks (derived from dist/all.css)
HookKindValues or defaultDescription
.forma-sliderBlock class—Root grid (label element or wrapper) stacking header, input, bounds and description with a 0.5rem gap.
.forma-slider__boundsElement class—Wrapping flex row of minimum and maximum labels in small monospace text.
.forma-slider__headerElement class—Wrapping flex row for the label; space-between leaves room for an application-maintained value readout.
.forma-slider__inputElement class—The native range input: full width, 44px minimum height, accent-color from the active control token, dimmed when disabled, with the shared focus ring.
.forma-slider__labelElement class—Visible label text (0.9375rem, weight 650).
Keyboard interaction
KeysResult
ArrowLeft / ArrowDownDecreases by one step (native).
ArrowRight / ArrowUpIncreases by one step (native).
PageUp / PageDownChanges by a larger increment in most browsers (native, browser-dependent).
Home / EndSets the minimum or maximum value (native).
Events
EventDescription
input / changeinput fires continuously while dragging; change fires on release. Forma adds none.

Form behavior

A native range input: always submits a value (it cannot be empty), snaps to step, resets to its initial value and is excluded when disabled.

States

Slider states
StateHow it is expressedPresentation
DefaultvalueNative thumb and filled track in the accent color.
Hover / pressed:hover / :activeSlight saturation increase for emphasis; the thumb position is never animated.
Focus:focus-visibleTwo-tone focus ring around the input.
Disableddisabled attributeReduced opacity with a not-allowed cursor.

Accessibility

Forma provides

  • The native range input exposes role, value, min and max to assistive technology and supports keyboard stepping.
  • 44px minimum height and full width give a large pointer and touch target.
  • Bound labels are visible text and aria-hidden to avoid double announcement.

Your application supplies

  • Label the scale and its unit; when the number matters, show the current value as text and keep it in sync.
  • Never make dragging the only way to set a value: keyboard stepping stays native, and offer a Numeric stepper for exact entry.
  • In the canonical label-wrapped structure a description inside the label joins the accessible name; keep it short or use a wrapper root with for/id.

Responsive behavior

  • The input fills its container at every width; a longer track gives finer pointer control.
  • Header and bounds rows are wrapping flex rows with min-inline-size: 0, so long labels wrap rather than overflow.
  • No breakpoints.

Motion

  • The value and thumb position are direct manipulation and are never transitioned.
  • Only the hover and press emphasis (a saturation filter) and disabled opacity use a short perceptual interpolation.
  • Under prefers-reduced-motion: reduce the emphasis transition is effectively instant.

Usage guidance

Do

  • Use words at the bounds when numbers mean little to users.
  • Choose a step that users can hit reliably by keyboard.

Avoid

  • Sliders for precise values or very large ranges.
  • Hiding the scale's meaning in a tooltip that only appears on hover.

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.