Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 05 Choices

Slider

A value picked along a range, such as a price limit or a volume. It is the browser's own range input, so arrow keys, Page Up and Down, Home and End all move it, and the value is written beside the label. For an exact number, use a number field.

Use it in Angular
import { SliderComponent } from '@okaapi-ui/angular';
// The value is a number. Works with formControlName, [formControl] and ngModel.

With a unit

format turns the number into what people read and hear, so a screen reader says EGP 500, not 500.

Only dishes under this price show.

Angular
<ui-slider
  label="Price limit"
  hint="Only dishes under this price show."
  [max]="2000"
  [step]="50"
  [format]="egp"
  formControlName="price"
/>

egp = (v: number) => `EGP ${v.toLocaleString('en')}`;

Disabled

Angular
volume = new FormControl({ value: 40, disabled: true });

In Arabic

The track fills from the right.

Angular
<ui-slider label="أقصى سعر" [max]="2000" [step]="50"
  [format]="egp" formControlName="price" />

egp = (v: number) => `${v.toLocaleString('ar-EG')} جنيه`;

When to use something else

If you needUse
An exact valueNumber field
Show a level the reader cannot changeMeter

Inputs

NameTypeDefaultWhat it does
labelstring — Required. Names the slider.
min | maxnumber0 | 100The ends of the range.
stepnumber1How far one arrow key press moves it.
format(value: number) => string — The value as shown and as read aloud, with its unit.
hintstring — Help under the slider, read after the label.

Keyboard and screen readers

KeysWhat they do
Left or Right or Up or Down Move by one step.
Page Up or Page Down Move by a bigger step.
Home or End Go to the lowest or highest value.
  • The browser’s own range input, named by its label; the value is also written beside it.