Dual Input Range Slider#
DualInputRangeSlider is a Dash All-in-One (AIO) component that integrates a range slider with
two number input fields for precise control of lower and upper bound values. It provides a
dual-control interface where users can adjust values by dragging the slider handles or typing
directly into the input fields.
Key features:
Dual control interface: Range slider with synchronized number inputs
Bidirectional updates: Changes in slider update inputs, and vice versa
Automatic validation: Ensures lower bound never exceeds upper bound
Customizable precision: Configurable decimal places for numeric inputs
Flexible styling: Customizable appearance for slider and input fields
Usage#
Basic usage#
Import DualInputRangeSlider:
from ansys.solutions.dash_super_components import DualInputRangeSlider
Add DualInputRangeSlider to the page layout:
def layout():
return html.Div(
[
DualInputRangeSlider(
min=0,
max=100,
aio_id="dual-input-range-slider",
)
],
style={"width": "500px"},
)
The following output is expected:
Advanced usage#
Customize the component with custom ranges, precision, and styling:
def advanced_layout():
return html.Div(
[
DualInputRangeSlider(
aio_id="custom-slider",
min=-1,
max=1,
step=0.1,
decimal_scale=2,
value=[0.2, 0.8],
slider_props={
"style": {"width": "450px"},
"marks": [
{"value": -1, "label": "-1"},
{"value": 0, "label": "0"},
{"value": 1, "label": "1"},
],
},
lower_bound_input_props={
"label": "Lower",
"style": {"width": "130px"},
},
upper_bound_input_props={
"label": "Upper",
"style": {"width": "130px"},
},
)
],
)
The following output is expected:
How it works#
Initialization: The component is created with required min and max values, plus optional step, decimal_scale, and initial value settings
Slider Control: Dragging the slider handles updates both the slider value and the corresponding number inputs
Input Control: Typing a new value in either number input and committing it (blur or Enter) updates the slider position. The inputs use
debounceto avoid triggering callbacks on every keystroke.Input Clamping: Values outside
[min, max]cannot be entered—the inputs use strict clamping to enforce the allowed range automatically.Automatic Validation: When a number input value would violate the constraint that lower bound ≤ upper bound, the component automatically adjusts the other bound to maintain validity:
If lower bound is set higher than current upper bound, upper bound is shifted to match
If upper bound is set lower than current lower bound, lower bound is shifted to match
Synchronized State: All three controls (slider and two inputs) stay synchronized at all times
Properties#
Constructor parameters#
Parameter |
Description |
Type |
Required |
|---|---|---|---|
min |
The minimum value of the slider. |
int or float |
Yes |
max |
The maximum value of the slider. Must be greater than min. |
int or float |
Yes |
step |
The step size for the slider and number inputs. Must be positive and less than or
equal to (max - min).
Default: |
int or float |
No |
decimal_scale |
The number of decimal places to display in the number inputs. Must be non-negative.
Default: |
int |
No |
value |
The initial values as a list of two elements |
list |
No |
slider_props |
Dictionary of properties for the |
dict |
No |
lower_bound_input_props |
Dictionary of properties for the lower bound |
dict |
No |
upper_bound_input_props |
Dictionary of properties for the upper bound |
dict |
No |
aio_id |
The unique identifier for the component. If not provided, a UUID is generated. |
str |
No |
Component IDs#
The component exposes the following IDs for use in callbacks:
DualInputRangeSlider.ids.slider(aio_id): The range slider componentDualInputRangeSlider.ids.lower_bound_input(aio_id): The lower bound number input componentDualInputRangeSlider.ids.upper_bound_input(aio_id): The upper bound number input component
Limitations#
The properties
min,max,step,value, andminRangeinslider_propsare controlled by the component and get overridden if specified.The property
minRangeis specifically set to0to ensure that the lower value is never greater than the upper value. This setting cannot be changed through the component’s configuration.The properties
min,max,step,value, anddecimalScaleinlower_bound_input_propsandupper_bound_input_propsare controlled by the component and get overridden if specified. Additionally,debounceis always set toTrue(callbacks trigger on blur/Enter, not on every keystroke) andclampBehavioris always set to"strict"(values outside[min, max]cannot be entered).
Full example#
For a complete working example with multiple slider configurations, check out the showcase example.
The example demonstrates:
A default slider with integer values (0–100) using only the required
minandmaxargumentsA customized slider with a narrower range (−1 to 1), a step of 0.1, two decimal places, and a pre-set initial selection of [0.2, 0.8]
A live output below the slider that updates as the handles are moved, using the
DualInputRangeSlider.ids.slider()component ID
For a minimal self-contained runnable example, see the Dual Input Range Slider page in the Examples gallery.
Source code#
For the full API reference of DualInputRangeSlider, see
DualInputRangeSlider.
Check out the component source code to discover the underlying logic. Contributions are welcomed. You can extend the component functionalities by raising a pull request in the dash-super-components package.