Range slider
Picks a range such as a price from 20 to 80. value is (low, high) and on_change receives the new pair. Pressing the track moves the nearer knob there and dragging keeps moving it; the knobs never cross.
ui.range_slider · Category: Forms · Full reference →


pz.container(ui.range_slider((20, 80), on_change, min=0, max=100, step=5, show_value=True), width=360)When to use
Section titled “When to use”- To filter by a range: prices, dates, sizes, years.
- For a single number, use Slider.
import pyzed as pzfrom pyzed import ui
class Shop(pz.App): def __init__(self): self.price = (20, 80)
def view(self): return ui.range_slider(self.price, lambda value: setattr(self, "price", value), min=0, max=500, step=5, show_value="{:.0f} €")Variants
Section titled “Variants”Options
Section titled “Options”

Code
pz.container(ui.range_slider((0.2, 0.7), on_change), width=320)

show_value=TrueCode
pz.container(ui.range_slider((10, 60), on_change, min=0, max=100, step=1, show_value=True), width=360)

show_value="{:.0f} €"Code
pz.container(ui.range_slider((50, 250), on_change, min=0, max=500, step=10, show_value="{:.0f} €"), width=380)

tint="success"Code
pz.container(ui.range_slider((30, 90), on_change, min=0, max=100, tint="success"), width=320)States and events
Section titled “States and events”

disabled=TrueCode
pz.container(ui.range_slider((20, 80), on_change, min=0, max=100, disabled=True), width=320)Events
Section titled “Events”Range slider has 2 events of its own, listed below. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.
| Event | Handler gets | When |
|---|---|---|
on_change |
((low, high)) |
Callable that receives the new (low, high). |
on_release |
() |
Sent when the knob is let go (save or apply there). |
Handler gets is what Pyzed passes to your callable: () means nothing. Any handler can also be a message (a value that is not callable), which goes to update().
Handling the events
Section titled “Handling the events”The same events written three ways. Imperative: methods of the app change self. Declarative: the handlers produce messages and one update() decides. Functional: a pure function draws an immutable state and asks for changes with set_state(...). See Imperative, declarative and functional.
class Shop(pz.App): def __init__(self): self.price = (20, 80)
def set_price(self, value): # on_change: the new (low, high) self.price = value
def search(self): # on_release: the knob was let go print("search", self.price)
def view(self): return ui.range_slider(self.price, self.set_price, min=0, max=100, step=5, on_release=self.search, show_value=True)from dataclasses import dataclass
@dataclassclass Price: value: tuple
class Shop(pz.App): price = (20, 80)
def update(self, message): match message: case Price(value): self.price = value
def view(self): return ui.range_slider(self.price, Price, min=0, max=100, step=5)from dataclasses import dataclass
@dataclass(frozen=True)class State: price: tuple = (20, 80)
def view(state, set_state): return ui.range_slider(state.price, lambda value: set_state(price=value), min=0, max=100, step=5)Properties and API
Section titled “Properties and API”ui.range_slider
Section titled “ui.range_slider”range_slider( value, on_change=None, *, min=0.0, max=1.0, step=0.01, min_gap=0.0, on_release=None, width='fill', tint='accent', disabled=False, show_value=False, theme=None,)A slider with two knobs that picks a range. Pressing the track moves the nearer knob there and dragging keeps moving it; the knobs never cross.
| Property | Default | Description |
|---|---|---|
value |
required | (low, high). |
min |
0.0 |
Smallest value. |
max |
1.0 |
Largest value. |
step |
0.01 |
Values snap to multiples of this. |
min_gap |
0.0 |
Smallest distance kept between both knobs. |
width |
"fill" |
Width: pixels, "fill", "shrink" or "fill:N" (proportion). |
tint |
"accent" |
Color of the range between the knobs. |
disabled |
False |
Disables it (ignores clicks). |
show_value |
False |
Adds low – high next to it: True, or a format for each end such as "{:.0f} €". |
theme |
None |
Theme to use instead of the current one (pyzed.theme.current()). |
Events: on_change, on_release (events).