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

Example output of the Dual Input Range Slider component

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:

Default configuration of the Dual Input Range Slider component

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:

Custom configuration of the Dual Input Range Slider component

How it works#

  1. Initialization: The component is created with required min and max values, plus optional step, decimal_scale, and initial value settings

  2. Slider Control: Dragging the slider handles updates both the slider value and the corresponding number inputs

  3. Input Control: Typing a new value in either number input and committing it (blur or Enter) updates the slider position. The inputs use debounce to avoid triggering callbacks on every keystroke.

  4. Input Clamping: Values outside [min, max] cannot be entered—the inputs use strict clamping to enforce the allowed range automatically.

  5. 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

  6. 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: (max - min) / 10.0.

int or float

No

decimal_scale

The number of decimal places to display in the number inputs. Must be non-negative. Default: 1.

int

No

value

The initial values as a list of two elements [lower, upper]. Both values must be within [min, max] and lower ≤ upper. Default: [min, max].

list

No

slider_props

Dictionary of properties for the dmc.RangeSlider component. Properties min, max, step, value, and minRange are controlled by the component parameters and get overridden if specified in this dictionary. The minRange property is set to 0 to ensure the lower value is never greater than the upper value. See dmc.RangeSlider properties. Default style: {"width": "60%"}.

dict

No

lower_bound_input_props

Dictionary of properties for the lower bound dmc.NumberInput component. Properties min, max, step, value, decimalScale, debounce, and clampBehavior are controlled by the component parameters and get overridden if specified in this dictionary. See dmc.NumberInput properties. Default: label: "Min", variant: "filled", style: {"width": "15%"}.

dict

No

upper_bound_input_props

Dictionary of properties for the upper bound dmc.NumberInput component. Properties min, max, step, value, decimalScale, debounce, and clampBehavior are controlled by the component parameters and get overridden if specified in this dictionary. See dmc.NumberInput properties. Default: label: "Max", variant: "filled", style: {"width": "15%"}.

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 component

  • DualInputRangeSlider.ids.lower_bound_input(aio_id): The lower bound number input component

  • DualInputRangeSlider.ids.upper_bound_input(aio_id): The upper bound number input component

Limitations#

  • The properties min, max, step, value, and minRange in slider_props are controlled by the component and get overridden if specified.

  • The property minRange is specifically set to 0 to 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, and decimalScale in lower_bound_input_props and upper_bound_input_props are controlled by the component and get overridden if specified. Additionally, debounce is always set to True (callbacks trigger on blur/Enter, not on every keystroke) and clampBehavior is 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 min and max arguments

  • A 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.