✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Togglers / Switcher style - How to do create a switcher with labels and squared

Hey Fellows,

I’m trying to build an application where I have a switcher like the one below:


How can I build something like this component using Dash or Dash bootstrap?

I have tried dash.daq and also the Checklist of dash bootstrap but no one of these components worked/seem like I need;

I would be very grateful if someone can help me with it

I have adapted a dcc.Tabs component to build it:


I would love to see a better solution, but as it is working for me, I will use it for now; Let me know if you have a better option !

tabs_styles = {
    'height': '35px',
    'border': "4px solid #5a5454",
tab_style = {
    'padding': '3px',
    'backgroundColor': 'lightgrey',
    'width': '50px',
    'height': '25px',

tab_selected_style = {
    'backgroundColor': '#425572',
    'color': 'white',
    'padding': '3px',
    'width': '50px',
    'height': '27px',
    'border': "1px solid #5a5454",

tab_switcher = dcc.Tabs(id="tabs-styled-with-inline", value='tab-1',
                            dcc.Tab(label='Count', value='tab-1', style=tab_style, selected_style=tab_selected_style, className="font-sm"),
                            dcc.Tab(label='%', value='tab-2', style=tab_style, selected_style=tab_selected_style, className="font-sm"),
                        ], style=tabs_styles)

1 Like