Skip to content

Instantly share code, notes, and snippets.

@AnnMarieW
Created September 29, 2022 21:10
Show Gist options
  • Save AnnMarieW/e3129e20f432ba2853efa93f4917a621 to your computer and use it in GitHub Desktop.
Save AnnMarieW/e3129e20f432ba2853efa93f4917a621 to your computer and use it in GitHub Desktop.
Multi Dropdown with a Select All button
from dash import Dash, dcc, html, Input, Output
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
options = ["apples", "oranges", "bananas", "chocolate"]
app.layout = dbc.InputGroup(
[
dcc.Dropdown(options, multi=True, id="fruit", style={"width":400}),
dbc.Button("Select All", id="all"),
]
)
@app.callback(
Output("fruit", "value"),
Input("all", "n_clicks"),
prevent_initial_call=True
)
def select_all(_):
return options
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment