Skip to the page content

Sliders & rating

Sliders for one value or a range, and rating fields from stars to a numbered scale.

10 field types

Slider sizes and states

The single slider and its options: the value in the label row, a bubble over the thumb while it moves, numbered ticks, a small size, a track color that follows the value, and disabled with the reason under it.

Slider

Default

$40

Set to $0 to ship every order free.

Value bubble

The value shows above the thumb on hover, focus and drag.

Numbered ticks

3 months

Small

Drop-in

Color follows value

10 days

Comfortable. Under 10 turns amber, under 5 red.

Disabled

8.5%

Set by your shipping region in Tax settings.

Show code
<input type="range" class="sr-range" data-sr-out="#out">      <!-- value in the label row -->
<input type="range" class="sr-range" data-sr-bubble>         <!-- plus <span class="sr-bubble"> -->
<input type="range" class="sr-range" data-sr-ticks>          <!-- a number under every step -->
<input type="range" class="sr-range sr-range-sm">           <!-- small -->
<input type="range" class="sr-range" data-sr-toned>          <!-- color follows the value -->
<input type="range" class="sr-range" disabled
       aria-describedby="txr-help">                          <!-- locked, reason below -->

Slider with number field

Drag for a rough figure, then type or step for the exact one. The slider and the stepper share one value and one step, and labeled marks point out values that matter on the track.

Slider
seats

5 to 200 seats in steps of 5. The marks sit at the 20, 50 and 100 seat volume discounts.

Show code
<div class="basalt-stepper basalt-stepper-sm" data-basalt-stepper>…</div>
<input type="range" class="sr-range" id="sr-seats" min="5" max="200" step="5">
<div class="sr-marks" data-sr-marks="20,50,100"></div>

range.addEventListener('input', () => { box.value = range.value; });
box.addEventListener('change', () => { range.value = box.value; });

Stepped slider with labels

A slider with a handful of named stops instead of numbers. Every stop has a word under it that can be clicked, and the slider sets aria-valuetext, so a screen reader says the word, not the number.

Slider
Normal
Half day
Senior
Show code
<input type="range" class="sr-range" min="1" max="5" value="3"
       data-sr-labels="Lowest|Low|Normal|High|Emergency"
       data-sr-out="#priority-out" data-sr-ticks>

// Sets aria-valuetext, so "Normal" is read out, not "3".

Range slider with histogram

Two handles on one track pick a minimum and a maximum. Bars above the track show how the values are spread, and the Min and Max boxes take typed numbers. The handles never cross and keep a set gap.

Range slider
$
$

Whole dollars from $8 to $60. A typed value outside that, or past the other handle, is pulled back in.

21 of 40 items

Show code
<div class="sr-histo" aria-hidden="true" data-sr-histo></div>
<div class="sr-dual" data-sr-dual data-gap="4">
  <span class="sr-dual-fill"></span>
  <input type="range" class="sr-dual-input" min="8" max="60" value="14" data-sr-end="lo">
  <input type="range" class="sr-dual-input" min="8" max="60" value="32" data-sr-end="hi">
</div>

// Each handle stops data-gap short of the other; typed
// values go through the same rule with wrap.srSet(lo, hi).

Time range slider

Two handles across a day, in 30-minute steps. The values are minutes from midnight but show and read out as clock times, and the range can't shrink below two hours.

Range slider
Service window 9:00 am to 1:00 pm

7 am to 9 pm, at least 2 hours apart. Now 4 hours.

Show code
<div class="sr-dual" data-sr-dual data-gap="120" data-sr-time>
  <input type="range" min="420" max="1260" step="30" value="540">
  <input type="range" min="420" max="1260" step="30" value="780">
</div>

// Minutes from midnight; aria-valuetext reads "9:00 am".

Star rating input

Five radio buttons drawn as stars, so arrow keys move between them. Hovering previews a score, a word beside the stars says what it means, and a required rating shows an error. Comes in a large and a small size.

Star rating
Overall, required

Small size, optional

Punctuality
Workmanship
Tidiness

Show code
<fieldset class="sr-stars sr-stars-lg" data-sr-stars>
  <legend>Overall</legend>
  <input type="radio" class="visually-hidden" name="overall" id="o-1" value="1">
  <label for="o-1" data-sr-word="Not for me">
    <i class="bi bi-star-fill" aria-hidden="true"></i>
    <span class="visually-hidden">1 star, not for me</span>
  </label>
  …
</fieldset>

<fieldset class="sr-stars sr-stars-sm" data-sr-stars>…</fieldset>

Read-only star rating

For showing a score rather than asking for one. The stars fill to the exact decimal, come in three sizes and carry a text label for screen readers. Pair them with a bar per score for a breakdown.

Star rating

4.6

1,284 reviews

  • 5 stars74%
  • 4 stars17%
  • 3 stars5%
  • 2 stars2%
  • 1 star2%
  • Large, 4.6
  • Default, 3.5
  • Small, 2.2
Show code
<span class="sr-readonly share-92"
      role="img" aria-label="4.6 out of 5 stars">
  <span class="sr-readonly-on"></span>
</span>
<!-- sizes: sr-readonly-lg, sr-readonly-sm -->

/* The lit layer is clipped to score / 5 of the width. */
.sr-readonly-on { width: calc(var(--sr-score) / 5 * 100%); }

Thumbs up and down

Two toggle buttons using aria-pressed, for yes or no feedback. One vote each: pressing the other thumb moves the vote and pressing the same one takes it back. Shown with a running count, or as icons only.

Rating scale

Was the first-visit checklist useful?

Did this answer your question?

Show code
<div role="group" aria-labelledby="q">
  <button type="button" class="sr-thumb" data-sr-thumb="up" aria-pressed="false">
    <i class="bi bi-hand-thumbs-up" aria-hidden="true"></i>Yes
    <span class="sr-thumb-n" data-sr-thumb-n>212</span>
  </button>
  <button type="button" class="sr-thumb sr-thumb-icon" aria-label="No" …>…</button>
</div>

Face rating

Five faces as radio buttons, each with a word under it, for a one-tap answer. Picking a face reveals follow-up checkboxes that fit it: problems for a low score, praise for a high one.

Rating scale
How was your visit?

Show code
<fieldset class="sr-faces">
  <legend>How was your visit?</legend>
  <input type="radio" class="visually-hidden" name="face" id="face-5" value="5">
  <label for="face-5">
    <i class="bi bi-emoji-laughing" aria-hidden="true"></i><span>Great</span>
  </label>
  …
</fieldset>

0 to 10 scale

Eleven numbered radio buttons with the meaning of each end spelled out. The numbers are tinted in three bands, 0 to 6, 7 to 8 and 9 to 10, and the follow-up question changes with the band. The standard field for NPS and likelihood questions.

Rating scale
How likely are you to recommend Fieldline to a colleague?
0 means not at all likely10 means extremely likely

Show code
<fieldset aria-describedby="nps-ends">
  <legend>How likely are you to recommend…</legend>
  <!-- 11 radios, built by the script -->
  <input type="radio" name="nps" id="nps-0" value="0" class="visually-hidden">
  <label for="nps-0" class="sr-nps-n is-detractor">0</label>
</fieldset>

band = score >= 9 ? 'promoter' : score >= 7 ? 'passive' : 'detractor';

Good to know

  • Use a slider when a rough value is fine. When the exact number matters, pair it with a stepper or a text box.
  • Always show the current value next to the slider, not only while it is being dragged.
  • Five stars is plenty. Say what the ends mean.
  • Sliders are native <input type="range">, so arrow keys, Home, End, Page Up and Page Down all work.
  • Stepped sliders set aria-valuetext, so a screen reader says "Normal", not "3".
  • Stars, faces and the 0 to 10 scale are radio buttons inside a <fieldset> with a <legend>. Thumbs are toggle buttons with aria-pressed.