dash-bootstrap-components icon indicating copy to clipboard operation
dash-bootstrap-components copied to clipboard

Allow icons and html in `dbc.AccordionItem()` title

Open GitHunter0 opened this issue 2 years ago • 2 comments

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

GitHunter0 avatar Oct 17 '23 16:10 GitHunter0

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

tcbegley avatar Oct 17 '23 18:10 tcbegley

Thanks man, I appreciate the feedback.

GitHunter0 avatar Oct 17 '23 19:10 GitHunter0

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)

tcbegley avatar Apr 14 '24 22:04 tcbegley