Created
September 29, 2022 21:10
-
-
Save AnnMarieW/e3129e20f432ba2853efa93f4917a621 to your computer and use it in GitHub Desktop.
Multi Dropdown with a Select All button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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