How to create space between two sliders

Hey guys,

Does anyone know how to insert space between two sliders that are in the same row?

Code and result are attached below:

sliders1 = row(sliders[:],width = 2000, height = 50)

Hi @Li_Shen!

You’d want to add a margin to each Slider. Here’s an example:

from bokeh.layouts import row
from bokeh.models import Slider
from bokeh.plotting import show

slider_margin = (0, 10, 0, 10)

s1 = Slider(start=0, end=10, value=0, step=1, title="First", margin=slider_margin)
s2 = Slider(start=10, end=20, value=10, step=1, title="Second", margin=slider_margin)
s3 = Slider(start=20, end=30, value=20, step=1, title="Third", margin=slider_margin)

r = row(s1, s2, s3)

show(r)

The margin tuple is (top, right, bottom, left). Reference is here.

1 Like

Hi Carolyn,

It works! Thank you!

2 Likes

A better solution is to use item spacing, e.g.:

from bokeh.layouts import row
from bokeh.models import Slider
from bokeh.plotting import show

s1 = Slider(start=0, end=10, value=0, step=1, title="First")
s2 = Slider(start=10, end=20, value=10, step=1, title="Second")
s3 = Slider(start=20, end=30, value=20, step=1, title="Third")

r = row(s1, s2, s3, spacing=10)

show(r)
3 Likes

You’re right, that’s way better! I had overlooked that option in the Row reference. Thanks!