Skip to content

Instantly share code, notes, and snippets.

@AnnMarieW
Created September 25, 2022 16:27
Show Gist options
  • Save AnnMarieW/2968c6cf9a3d58806685139c59fc5c13 to your computer and use it in GitHub Desktop.
Save AnnMarieW/2968c6cf9a3d58806685139c59fc5c13 to your computer and use it in GitHub Desktop.
Dropdown with Bootstrap theme color swatch
# todo -add images for other themes
from dash import Dash, html, dcc
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
themes = {
"bootstrap " : "https://user-images.githubusercontent.com/72614349/192116714-37bb83f2-523b-4709-876b-ef9296ae8045.png",
"cyborg " : "https://user-images.githubusercontent.com/72614349/192116901-89a5900a-0559-4272-96bc-539db4dbed07.png"
}
options = [
{
"label": html.Div(
[
html.Span(theme),
html.Img(src=img, height=30),
],
className="align-middle"
),
"value": theme,
} for theme, img in themes.items()
]
app.layout = html.Div(
[
dcc.Dropdown(options)
]
)
if __name__ == "__main__":
app.run_server(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment