dash-bootstrap-components
dash-bootstrap-components copied to clipboard
Allow icons and html in `dbc.AccordionItem()` title
Hey folks,
dbc.AccordionItem() title only accepts a string. I'd like to use an icon instead of a string, is it possible?
Thank you
Hey,
Unfortunately not currently possible. I have an idea for how we could reimplement the component to support this that I want to try at the next opportunity.
In the meantime you could try this workaround
Thanks man, I appreciate the feedback.
This is now possible pip install -U dash-bootstrap-components
import dash_bootstrap_components as dbc
from dash import Dash, html
app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = dbc.Container(
dbc.Accordion(
[
dbc.AccordionItem(
html.P("This is the content of the first section"),
title=html.Span("Item 1", style={"color": "red"}),
),
dbc.AccordionItem(
html.P("This is the content of the second section"),
title=html.Span("Item 2", style={"color": "cyan"}),
),
],
),
className="p-5",
)
if __name__ == "__main__":
app.run_server(debug=True)