Skip to content

Slider

Get Ritla UI

Pick a value or a range by dragging or with the keyboard, when the feel matters more than the exact number: volume, zoom, a price range.

Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add slider

    Also works with shadcn: npx shadcn@latest add @ritla/slider

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

slider.tsx
import { Slider } from "@/components/ui/slider";<Slider aria-label="Volume" defaultValue={40} /><Slider aria-label="Price" min={0} max={1000} step={50} defaultValue={[200, 800]} />

Examples

Sizes

xs to xl: a 16, 24, 40, 56 or 96px track.

EnglishMirroredArabic
LTR →

Circle handle and stops

handleStyle="circle", and showStops puts a dot at every step when only certain values are allowed.

EnglishMirroredArabic
LTR →

Centered

Fills from the middle of the range toward the value, for values that go below or above zero.

EnglishMirroredArabic
LTR →

Range

Two values [from, to] with two handles, each named for screen readers.

EnglishMirroredArabic
LTR →

Vertical

Fills from the bottom in both directions; Up and Down move it.

EnglishMirroredArabic
LTR →

Disabled

EnglishMirroredArabic
LTR →

API reference

Slider

PropTypeDefaultDescription
size"xs" | "sm" | "md" | "lg" | "xl""xs"Figma's Size: XSmall to XLarge.
handleStyle"line" | "circle""line"Figma's Handle style.
showStopsbooleanfalseFigma's Show stops: a dot at every step. Without it, only the end of an empty track gets a dot.
centeredbooleanfalseFigma's Centered slider: fills from the middle of the range.
orientation"horizontal" | "vertical""horizontal"Figma's Vertical slider.
value / defaultValuenumber | [number, number]NoneA number, or [from, to] for Figma's Range slider.
min / max / stepnumber0 / 100 / 1The value's bounds and step.
largeStepnumber10The Page Up / Page Down step.
onValueChange / onValueCommitted(value) => voidNoneWhile dragging, and on release.
showValuebooleantrueThe value bubble while dragging or when focused from the keyboard.
formatIntl.NumberFormatOptionsNoneHow the value reads in the bubble and to screen readers (currency, percent).
numerals"latn" | "arab"NoneNumeral system; defaults to RitlaProvider's.
disabledbooleanfalseFigma's State = Disabled.
aria-labelstringNoneThe slider's name ("Volume").

Usage guidelines

A slider picks an approximate value or a range by dragging. Which slider to pick, how to show values, which size and handle, and the checks before handoff.

1. Which slider

Four sliders share one look. Pick by what is being chosen. When the value must be exact, or there are only a few options, a slider is the wrong control.

You need toUseWhy
Set one approximate value: volume, brightness, a budgetSliderFills from the inline start; drag until it feels right.
Set a range: price from and toRange sliderTwo handles; the fill shows the range.
Adjust around a neutral point: balance, exposureCentered sliderFills from the middle toward minus or plus.
Volume or zoom in a vertical toolbarVertical sliderFills from the bottom, the same in both directions.
Enter an exact amount, like a transferNumber inputTyping 1,250 is faster and exact.
Pick one of 2 to 5 named levelsToggle group or Radio groupNamed options read better than stops.

Approximate, not exact

A price filter, and a transfer amount.

Do: Range for a price filter“Around 20 to 80” is exactly what a filter needs.
Don't: Slider for a transfer amountLanding on 1,250 JOD by dragging is nearly impossible; type it.

2. Values and precision

Show the current value while dragging (the value indicator) and next to the label at rest. Show the minimum and maximum when they matter. When people may need a precise value, pair the slider with a Number input that stays in sync. Use stops only when just a few values are allowed.

Do

  • Show the value next to the label, with its unit: 20 to 80 JOD.
  • Show min and max under the track when they give context.
  • Pair with a Number input when an exact value is sometimes needed.
  • Snap to stops when only certain values are valid.

Don't

  • Hide the current value; people guess.
  • Use a step so fine that the handle jumps under the finger.
  • Use stops for more than about ten values.

3. Sizes and handles

Five sizes from xs to xl share the same proportions. Use md in forms and filters, lg or xl where thumbs do the work, xs and sm only in dense desktop tools. Line is the default handle, in Figma and in code; Circle reads as draggable on touch, so it suits mobile.

Do

  • Use md by default, lg or xl on touch screens.
  • Start from the Line handle; switch to Circle on mobile.
  • Keep one size and handle style per screen.

Don't

  • Use xs on a phone; the handle is too small to grab.
  • Mix Line and Circle handles in one filter panel.

4. Arabic and RTL

A horizontal slider fills from the inline start, so in Arabic it fills from right to left: the minimum is on the right, the maximum on the left, and ArrowLeft increases the value. Use the RTL variant; it mirrors the track, fill and range. Centered sliders put minus on the right. Vertical sliders don't change. Values follow the numerals setting.

It fills from the inline start

A brightness setting in Arabic.

Do: RTL variantIt fills from the right, where the Arabic line starts; 0 sits on the right.
Don't: LTR variant on an Arabic screenIt fills from the left, so more looks like less to an Arabic reader.

Before handoff

  • A slider only for approximate values or ranges.
  • Label, current value, min and max are designed.
  • Step, stops and any paired Number input are noted.
  • Arabic screens use RTL variants, with min on the right.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
ArrowRightArrowUpIncreases by one step. In Arabic, ArrowLeft increases.
ArrowLeftArrowDownDecreases by one step. In Arabic, ArrowRight decreases.
PageUpPageDownChanges by largeStep.
HomeEndJumps to the minimum or the maximum.

ARIA

  • Each handle is role="slider" with aria-valuemin, aria-valuemax and aria-valuenow, and value text in the same format and numerals.
  • In a range, the handles are named "…, from" and "…, to".
  • For precise amounts like a transfer amount, use a field, or pair one with the slider.

Do

  • A label on each slider, and a name on both range handles: “Minimum price”, “Maximum price”.
  • Arrows move one step, Page Up and Page Down ten, Home and End to the ends.
  • Readable values with units: “35 JOD”.
  • A handle of at least 48 px on touch screens.

Don't

  • Rely on the fill color alone.
  • A slider as the only way to set an exact value.

Arabic and RTL notes

Mirrors

  • Horizontal sliders fill from the right: the minimum sits on the right, and ArrowLeft increases.
  • Range and centered sliders mirror the same way.

Does not mirror

  • Vertical sliders fill from the bottom in both languages.
  • The circle handle's icon is symmetric and doesn't flip.
Numerals
The value bubble and the screen reader text use the chosen numerals (0123456789 or ٠١٢٣٤٥٦٧٨٩) and the language's formatting.
Arabic typography
numeric-14 Medium in the bubble, the figures style.
Mixed-direction text
The value is isolated in the bubble, so a currency sign or minus stays in place.

Do

  • The RTL variant for every horizontal slider on Arabic screens.
  • The minimum label on the right, the maximum on the left.
  • Values in the numerals setting, with Arabic units.

Don't

  • The LTR variant on an Arabic screen; it fills backwards.
  • Flip it by hand.
  • Mirror a vertical slider.

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)