Skip to main content

mo.ui.slider

Create a numeric slider for selecting values from a range.

Signature

mo.ui.slider(
    start: Numeric | None = None,
    stop: Numeric | None = None,
    step: Numeric | None = None,
    value: Numeric | None = None,
    debounce: bool = False,
    *,
    label: str = "",
    on_change: Callable[[Numeric], None] | None = None,
    disabled: bool = False,
    orientation: Literal["horizontal", "vertical"] = "horizontal",
    show_value: bool = False,
    include_input: bool = False,
    steps: Sequence[Numeric] | None = None,
    full_width: bool = False
)

Parameters

start
Numeric
Minimum value of the slider range
stop
Numeric
Maximum value of the slider range
step
Numeric
Increment between values
value
Numeric
Initial value (defaults to start)
debounce
bool
default:"False"
Only send value on mouse-up/drag-end
label
str
default:"''"
Markdown label for the slider
disabled
bool
default:"False"
Whether the slider is disabled
orientation
'horizontal' | 'vertical'
default:"'horizontal'"
Slider orientation
show_value
bool
default:"False"
Display current value
include_input
bool
default:"False"
Show editable input field
steps
Sequence[Numeric]
Custom step values (mutually exclusive with start/stop/step)

Examples

import marimo as mo

# Basic slider
slider = mo.ui.slider(start=0, stop=100, step=1)
slider
# Slider with value display
slider = mo.ui.slider(
    start=0,
    stop=10,
    step=0.1,
    value=5,
    label="**Temperature**",
    show_value=True
)
# Custom steps (logarithmic scale)
import numpy as np

log_slider = mo.ui.slider(
    steps=np.logspace(0, 3, 10),
    label="Log scale"
)

Creating from DataFrame

slider = mo.ui.slider.from_series(df["age"])

Build docs developers (and LLMs) love