Updated: March 7, 2023

Slider

sap.m.Slider

Intro

A slider is a control that enables the user to adjust single values within a specified numerical range.

Slider example
Slider example

Usage

Use the slider to change values with graphical support.

Responsiveness

The slider itself is not responsive. It adjusts to the responsiveness of its parent container by recalculating and resizing the width of the control.

The slider supports the cozy and compact form factors. The compact form factor is used for apps that run on devices operated by a mouse and keyboard.

Types

Only a horizontal slider is available.

Behavior and Interaction

Changing the Value

If the slider is editable, the hand cursor appears when the user hovers over the grip.

The user can change the slider setting in two ways:

  • By using drag and drop to adjust the grip
  • By clicking the bar. The grip then moves to this new position.

The grip can be moved with or without increments based on the predefined steps.

Changing the value
Changing the value

Slider with Text Fields

The slider can be used with text fields instead of tooltips. In this case, the value of the grip is displayed.

Slider with text field
Slider with text field

Slider with Input Fields

The slider can be used with input fields instead of text fields. This allows the user to enter a specific value.

Slider with input field
Slider with input field

Slider with Tick Marks

You can apply tick marks to the slider. The tick marks are related to the step property, and are responsive. If the distance between 2 tick marks is less than 8 px, all tick marks except for the first and last disappear.

Slider with tick marks
Slider with tick marks

Slider with Tick Marks and Labels

If tick marks are set, you can define labels for the tick marks. The labels are displayed below the tick marks and show the corresponding value of the tick mark. The labels must always be numbers, and must never overlap. You can also define labels only for specific tick marks if you don’t need a label for every tick mark on the slider. The application developer is responsible for defining a reasonable set of tick marks.

If there is not enough horizontal space to display all the labels, a responsive mechanism is activated. The first and the last label are always visible.

Slider with tick marks and labels
Slider with tick marks and labels

Custom Values

You can define custom values as labels. This can be useful if your scenario requires descriptive intervals, such as as dates. Always keep the values as short and meaningful as possible.

Slider with custom values as labels
Slider with custom values as labels
Developer Hint
In order to use custom scales in a slider, you must map them to the floats for the slider scale.

Styles

The slider can be shown with or without a progress bar. By default, the progress bar is shown.

Examples

Slider without progress bar
Slider without progress bar
Slider with progress bar
Slider with progress bar

Properties

  • The step property must be positive. If a negative number is provided, the default value 1 is used instead.
  • The minimum, maximum, and value properties can be decimals (float values). The slider automatically sets the minimum value to 0 and maximum value to 100 by default.
  • The width of the control can be provided in %, em, px, and all possible CSS units. The slider automatically sets the width of the slider to 100% by default.

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation