Nasaq
Components

Slider

Draggable single-value or range slider with marks, a Nasaq-formatted value label, disabled state and Field wiring. Wraps Base UI Slider.

PreviewOpen ↗

Code

import { Slider } from "@fadymondy/nasaq/web";export function Volume() {  return <Slider label="Volume" defaultValue={40} />;}

Forms · beta

Live examples and controls: Slider in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/slider.json

Picks a number, or a range of two numbers, by dragging a thumb along a track. Pass a number for one thumb or an array for a range. The value label uses Nasaq number formatting (Western digits in Arabic too). Built on Base UI Slider.

When to use

  • Choosing an approximate value on a scale: volume, quality, a price range filter.
  • A range where dragging is faster than typing two numbers.

When not to use

  • An exact figure the user must type: use an Input.
  • Showing a value the user cannot change: use Progress or Meter.
  • Two to five named options: use ToggleGroup or RadioGroup.

Import

import { Slider } from "@fadymondy/nasaq/web";

Quick start

import { Slider } from "@fadymondy/nasaq/web";

export function Volume() {
  return <Slider label="Volume" defaultValue={40} />;
}

Anatomy

<Slider>                      data-slot="slider"
├─ slider-head                label + value row
│  └─ slider-value            formatted value(s)
├─ slider-control             data-slot="slider-control"
│  └─ slider-track
│     ├─ slider-range         the filled part
│     └─ slider-thumb         one per value
└─ slider-marks               optional ticks, aria-hidden

API

Slider (SliderProps)

All Base UI Slider.Root props except orientation, format and children, plus:

PropTypeDefaultDescription
value / defaultValuenumber | number[]noneA number is one thumb; an array is a range.
onValueChange(value, details) => voidnoneCalled while dragging.
onValueCommitted(value, details) => voidnoneCalled when the drag or key press ends.
min / max / stepnumber0 / 100 / 1Scale.
labelReactNodenoneVisible name above the track.
showValuebooleantrue when label is setShow the formatted value at the inline end.
formatFormatNumberOptionsnoneIntl options, e.g. { style: "percent" }. Also used for the spoken value.
marksreadonly SliderMark[] | booleannoneTicks under the track; true = one per step.
thumbLabelsreadonly string[]noneAccessible name per thumb in a range.
disabledbooleanfalseBlocks input.
namestringnoneForm field name.

SliderMark: { value: number; label?: ReactNode }.

Examples

Price range in Arabic:

import { Slider } from "@fadymondy/nasaq/web";

export function PriceAr() {
  return (
    <Slider
      label="نطاق السعر"
      min={0}
      max={10000}
      step={100}
      defaultValue={[1200, 8500]}
      format={{ style: "currency", currency: "SAR", maximumFractionDigits: 0 }}
      thumbLabels={["الحد الأدنى", "الحد الأقصى"]}
    />
  );
}

Inside a Field:

import { Field, FieldDescription, FieldLabel, Slider } from "@fadymondy/nasaq/web";

export function Seats() {
  return (
    <Field name="seats">
      <FieldLabel>Seats</FieldLabel>
      <Slider aria-label="Seats" defaultValue={10} min={1} max={50} showValue />
      <FieldDescription>You can change this later.</FieldDescription>
    </Field>
  );
}

Accessibility

KeyAction
TabMoves focus to a thumb.
ArrowRight / ArrowUpIncreases by one step (in RTL, ArrowLeft increases).
ArrowLeft / ArrowDownDecreases by one step.
PageUp / PageDownLarger step.
Home / EndMinimum / maximum.
  • Each thumb is an input type="range". Name it with label, aria-label or thumbLabels and localise those.
  • Marks are decorative (aria-hidden); the value is spoken through aria-valuetext.

RTL & i18n

The fill starts at the inline start, so in RTL it grows from the right and arrow keys follow the direction (from the NasaqProvider direction). Marks are placed with inset-inline-start. Values are formatted with Western digits in every locale.

Styling & tokens

bg-nq-surface-soft track, bg-primary range, bg-card thumb with border-primary, focus ring nq-focus. State attributes: data-disabled, data-dragging. className merges onto the root.

Do / Don't

  • Do show the value; a bare slider is imprecise.
  • Don't use it for values that need exactness.

progress, field, numeric.

Lab

https://docs.nasaqui.com/?path=/docs/components-forms-slider--docs

On this page