Skip to content

Instantly share code, notes, and snippets.

@AnnMarieW
Created June 20, 2022 00:42
Show Gist options
  • Save AnnMarieW/5e1ce9b87617361b2b27aa3b4e947b62 to your computer and use it in GitHub Desktop.
Save AnnMarieW/5e1ce9b87617361b2b27aa3b4e947b62 to your computer and use it in GitHub Desktop.
Cool way to make a "dropdown" using a dbc.Popover
import dash_bootstrap_components as dbc
from dash import Dash, html
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB, dbc.icons.BOOTSTRAP])
app.layout = dbc.Container(
[
html.Span(
[
html.I(className="bi bi-search pe-3", id="search"),
html.I(className="bi bi-list", id="menu"),
],
className="h2",
),
dbc.Popover(
dbc.Input(id="input", placeholder="search...", type="text"),
target="search",
body=True,
trigger="hover",
placement="bottom",
),
dbc.Popover(
dbc.ListGroup(
[
dbc.ListGroupItem(
[html.I(className="bi bi-bar-chart pe-3"), "bar chart"], href="/page1"
),
dbc.ListGroupItem(
[html.I(className="bi bi-graph-up pe-3"), "line chart"], href="/page2"
),
dbc.ListGroupItem(
[html.I(className="bi bi-pie-chart pe-3"), "pie chart"], href="/page3"
),
dbc.ListGroupItem(
[html.I(className="bi bi-download pe-3"), "download"], id="download"
),
],
className="h4",
),
target="menu",
body=True,
trigger="hover",
placement="bottom",
),
]
)
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