Slider
Adds Slider widget.
import mercury as mr
# add slider widget
your_slider = mr.Slider(value=5, min=0, max=10, label="Your favourite number", step=1)# access widget value in the code
print(f"Your value is {your_slider.value}")
Parameters
- value (integer)- the initial value of the widget, default is set to
0. - min (int) - minimum allowed value in the widget, default is set to
0. - max (int) - maximum allowed value in the widget, default is set to
10. - label (string) - the label that will appear near the widget.
- step (integer or float) - value of change, default is set to
1. - url_key (string) - set this value if you would like to set
Slidervalue with URL paramters. - disabled (boolean) - disable widget in the sidebar, default is set to
False. - hidden (boolean) - hide widget in the sidebar, default is set to
False.
Share widget value in URL
Let's create the Slider widget with url_key="slider":
import mercury as mr# init app settings
# set show_code=True
app = mr.App(title="MultiSelect", description="Demo of MutiSelect widget", show_code=True)# add widget
your_slider = mr.Slider(value=0, min=0, max=10, label="Your favourite number",
step=1, url_key="slider")
# access widget value in the code
print(f"Your value is {your_slider.value}")You can share the widgets values with other users. Please click the Share button in the sidebar bottom.
It will open a dialog with URL.
The URL will look like:
https://your-server-address.com/app/notebook-name?slider=3Please note that ?slider=3 is added at the end of URL address.
Example App
Below is a screenshot with example app. Example app is available at docs.runmercury.com/app/slider (opens in a new tab).

Notebook's code:
