Add Toggle buttons to dash app

For toggles, i usually use buttons. With buttons, you basically get the number of times it has been hit. You can then check the rest of the modulo to 2 of this number of times the button is clicked:

@app.callback(Output(......),
              [Input('toggle', 'n_clicks')])
def whatever(click):
    # Check if toggle on or of
    click = 2 if click is None else click
    toggle_on = True if click % 2 == 0 else False

    if toggle_on:
       pass
return ....

Would something like this help?

1 Like