Docs

Documentation versions (currently viewingVaadin 25.1 (pre-release))

Slider

Slider lets users pick a numeric value within a range by dragging a thumb along a track.

Slider is an input field that lets users pick a numeric value within a range by dragging a thumb along a track. Use arrow keys for precise adjustments.

Note
Preview Feature

This is a preview version of Slider and Range Slider. You need to enable it with the feature flag com.vaadin.experimental.sliderComponent. Preview versions may lack some planned features, and breaking changes may be introduced in any Vaadin version. We encourage you to try it out and provide feedback to help us improve it.

Source code
SliderBasic.java
slider-basic.tsx
slider-basic.ts

Range Slider

Range Slider is a two-thumb variant of Slider for selecting a numeric range. It supports the same features as Slider, but its value is a pair of numbers representing the start and end of the selected range.

Source code
RangeSliderBasic.java
range-slider-basic.tsx
range-slider-basic.ts

Min & Max Labels

The minimum and maximum values can be displayed below the slider track to give users a sense of the available range.

Source code
SliderMinMaxVisible.java
slider-min-max-visible.tsx
slider-min-max-visible.ts

Persistent Value Display

By default, the value bubble appears only when the user interacts with the slider. It’s possible to configure the slider to keep the value bubble visible at all times.

Source code
SliderValueAlwaysVisible.java
slider-value-always-visible.tsx
slider-value-always-visible.ts

Step

The step property controls the increment interval between selectable values. The default step is 1. Fractional values like 0.5 are supported for finer control. Steps are calculated relative to the min value.

Source code
SliderStep.java
slider-step.tsx
slider-step.ts

Basic Features

The following features, common to most input field components, are supported:

Label

The label is used to identify the input field. It supports plain-text content, and its length is limited to the width of the field. Helpers and Tooltips can be used to provide additional information that doesn’t fit into the label.

Visible labels are strongly recommended for all input fields. In cases where the built-in label cannot be used, an external element can be associated as the field’s label through the aria-labelledby attribute. Fields without any visible label should include an invisible label for assistive technologies with the aria-label attribute.

Helper

Helpers are used to provide additional information that the user may need to enter in the field, such as format requirements or explanations of the field’s purpose below the field.

A style variant is available for rendering the helper above the field.

In addition to plain text, helpers can contain components and HTML elements. However, complex and interactive content is likely to have accessibility issues.

Source code
SliderBasicFeatures.java
slider-basic-features.tsx
slider-basic-features.ts

Read-Only & Disabled

Fields used to display values should be set to read-only mode to prevent editing. Read-only fields are focusable and visible to screen readers. They can display tooltips. Their values can be selected and copied.

Fields that are currently unavailable should be disabled. The reduced contrast of disabled fields makes them inappropriate for displaying information. They can’t be focused or display tooltips. They’re invisible to screen readers, and their values cannot be selected and copied.

Disabled fields can be useful in situations where they can become enabled based on some user action. Consider hiding fields entirely if there’s nothing the user can do to make them editable.

Source code
SliderReadonlyAndDisabled.java
slider-readonly-and-disabled.tsx
slider-readonly-and-disabled.ts

Accessible Thumb Names

Range Slider has two thumbs, each with a default accessible name derived from the label (e.g., "Price range min" and "Price range max"). It’s possible to provide custom accessible names for each thumb to improve the experience for screen reader users.

Source code
RangeSliderAccessibleName.java
range-slider-accessible-name.tsx
range-slider-accessible-name.ts

Validation

Unlike other input fields, Slider and Range Slider don’t have built-in constraint validation. However, they do support invalid state and error messages, so you can implement custom validation logic.

The following example validates that the selected price range spans at least $200. Try narrowing the range to less than $200 to see the validation error:

Source code
RangeSliderCustomValidation.java
range-slider-custom-validation.tsx
range-slider-custom-validation.ts

Best Practices

Slider is best suited for settings where the user benefits from immediate visual feedback, such as adjusting volume or brightness. Range Slider is best suited for filtering or selecting a subset of a continuous range, such as a price range or date span.

When setting min, max, and step, choose values that result in a reasonable number of selectable steps. Too many steps make precise selection difficult; too few limit the user’s options.

Component Usage Recommendation

Number Field

For precise numeric input where exact values matter.