StartFoundationsComponentsContent

Slider

A slider sets an approximate number, or a range, by dragging a handle along a scale.

Stable Figma
OverviewUsageAPIAccessibility
<tk-slider label="Volume" value="60" show-value></tk-slider>

Anatomy

Part What it is
tk-slider the element; one Tab stop per handle
track the full scale
filled range from the start to the handle, or between the two handles in a range
handle the round grip you drag; the slider itself, for screen readers
value bubble an optional readout above the handle while you drag or focus it (show-value)
min and max labels optional labels at the ends (show-min-max)
tick marks optional marks at each step (marks)

Clicking the track moves the nearest handle there. The slider has no visible label: put one above it, and set label to the same words.

Range

<tk-slider range label="Price" min="0" max="500" step="10" value-start="100" value-end="300" show-value></tk-slider>
  • range adds a second handle. Read the bounds from value-start and value-end.
  • The handles can't cross. min-gap keeps them at least that many units apart.
  • Each handle is its own Tab stop. Screen readers hear them as "Price (minimum)" and "Price (maximum)".
  • For important ranges, also offer two number inputs. Two-handle sliders work unevenly with screen readers.

Scale and readout

<tk-slider label="Brightness" value="40" value-format="percent" show-min-max></tk-slider>
<tk-slider label="Rating" min="1" max="5" value="3" marks show-value></tk-slider>
  • min, max, and step set the scale. Values clamp to it and snap to step, with or without tick marks.
  • value-format="percent" shows the value as a percentage, in the bubble, the end labels, and for screen readers.
  • marks shows a tick at each step. Use it for a few steps, not a long scale.
  • For currency or units, set the format property to a function; it overrides value-format:
<tk-slider id="budget" label="Budget" max="1000" step="50" show-value></tk-slider>
<script>
  document.querySelector('#budget').format = (v) => `$${v}`;
</script>

Sizes

<tk-slider label="Medium slider" value="50"></tk-slider>
<tk-slider label="Small slider" size="small" value="50"></tk-slider>
size Track Handle Height
medium (default) 10px 18px 24px
small 4px 12px 24px

Both sizes are 24px tall, and each handle has a 24px target, so a slider fits a dense row without extra padding.

States

<tk-slider label="Bass" value="30" disabled></tk-slider>

The handle grows while you drag it. Keyboard focus shows a ring around the handle.

  • disabled: the slider is dimmed, can't be focused or changed, and isn't submitted.