Slider

core package3.2.2

Note: All components shown on this site are supported by the Constellation design system. To learn how to configure Theme Cosmos, visit Pega Community.

Sliders are inputs that allow a user to enter a numerical value within some range, or select a value by moving the Slider control. If you do not have a set range of values for a user to choose a number from, you should use the NumberInput component instead.

Usage

The Slider component consists of a Progress bar with optional ticks that denote value within a range of numbers. Users can slide the control on the bar to select an individual number within the given range defined by a min and max value. A step prop determines the multitude that each point on the Slider increments or decrements the current value. The Slider component also allows for standard Form Field structures such as being set required, disabled, or readOnly, as well as including a label, status, or info.

The bar on the Slider can optionally render an interactive color to help visual the value selected by enabling the showProgress prop. This component is also available in two orientations: horizontal and vertical.

You can show a preview of the value selected that will render as a read-only number. If you would like to accept manual user input, enable the showInput prop. Both the manual NumberInput and the preview will render below the Slider control. If both are enabled simultaneously, the preview will replace the input.

There are additional callback functions available to react to the user drag events.

Related components

Properties

NameDescriptionDefaultType
onChange*(value: number) => void
value*Creates a controlled input and sets the value. Requires an onChange handler to update value. value + onChange is the recommended method per React team.number
autoFocusWill automatically focus the thumb on render if trueboolean
classNameAdditional CSS classes.string
disabledDisable the control. The browser defaults to false.boolean
idSets DOM id for the control and associates label element via 'for' attribute. If an id is not pass, a random id will be generated for any render.string
infoIt is recommended to pass a simple string to offer guidance. Text will be styled based on status prop.ReactNode
labelPass a string or a fragment with an Icon and string.ReactNode
labelHiddenVisually hides the label region.boolean
maxMaximum value.100number
minMinimum value.0number
nameSets html name attribute for the underlying control. Useful for mapping to a data field.string
onDragEnd() => void
onDragStart() => void
orientationSlider orientation.'horizontal'
'horizontal' |'vertical' 
previewShow current value.falseboolean
readOnlyMakes the input non editable and non clickable. The browser defaults to false.boolean
requiredIndicate if the field is required. The browser defaults to false.boolean
showInputDisplay input to provide value.trueboolean
showProgressShow slider color progress bar.falseboolean
statusSet visual state based on a validation state.
'error' |'pending' |'success' |'warning' 
stepStep value.1number
ticksDisplay defined ticks.