The Slider component allows users to select a value from a bounded linear range of values. You can configure the slider by setting the minimum value, maximum value, step size, and the current value. The component also supports custom labels to describe the minimum and maximum values, as well as the slider itself. Additionally, it provides callbacks for handling value changes and editing state changes.
SliderProps defines the properties for the Slider component, which includes the following fields:
min (number):
max (number):
step (number):
1.value (number):
min and max.onChanged ((value: number) => void):
onEditingChanged ((value: boolean) => void):
value is true when editing starts, and false when editing ends.label (VirtualNode):
minValueLabel (VirtualNode):
SliderWithRangeValueLabelProps mode.maxValueLabel (VirtualNode):
SliderWithRangeValueLabelProps mode.SliderWithRangeValueLabelProps is a type that defines additional properties for labeling the slider's range. It includes:
label (VirtualNode):
minValueLabel (VirtualNode):
maxValueLabel (VirtualNode):
Here’s an example of using the Slider component:
In this example, the Slider component is configured with a range from 0 to 100, with the default value set to 50. Labels for the slider's purpose, as well as the minimum and maximum values, are provided.
min and max properties of the Slider must be numeric, and the value must be within this range.onChanged callback will trigger whenever the slider's value changes, passing the new value.SliderWithRangeValueLabelProps, you must provide appropriate view elements for minValueLabel and maxValueLabel.The Slider component is a versatile UI control suitable for scenarios where the user needs to select a numerical value. With its flexible properties and callbacks, it can handle a wide range of use cases, especially when labels for the minimum, maximum values, or the slider itself are needed.