You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bad behaviour] dcc.Slider marks misaligned with empty label in Dash 4 #3715
When creating custom marks for a dcc.Slider in Dash 4, the marks/ticks become misaligned if the label is empty. See this example slider:
The marks/ticks without label sink to the bottom of the mark+label box. In this example I used an empty string for an empty label. If I add some spaces there, the result is the same.
Use Dash 4.1.0 and this small app to replicate:
import dash
from dash import dcc, html
app = dash.Dash(__name__)
empty_label = ""
# empty_label = "\xa0"
marks = {val: (val if val % 10 == 0 else empty_label) for val in range(0, 151, 5)}
app.layout = html.Div(
[
html.H2("Dash 4 Slider tick misalignment"),
dcc.Slider(
id="slider",
min=0,
max=150,
step=None,
value=0,
marks=marks,
),
],
style={"width": "40%"}
)
if __name__ == "__main__":
app.run(debug=True)
I did find a (temporary) workaround. By taking an invisible unicode character as the empty label, for example: \xa0, it is possible to get the marks aligned again, see:
Though it would be nicer if we wouldn't have to rely on a hack like that.
Activity
AnnMarieW commentedon Apr 2, 2026
Hi @aGitForEveryone - thanks for reporting!
You can fix this by adding the following to a .css file:
If you feel like doing a PR, the
height: 12px;just needs to be added to the css file here: https://github.com/plotly/dash/blob/dev/components/dash-core-components/src/components/css/sliders.css#L95terminalchai commentedon Apr 2, 2026
I’m taking this one and will put up a small fix.