[Python] Apply dash-bootstrap theme to dcc components

Discussão em 'Python' iniciado por Stack, Novembro 30, 2025.

  1. Stack

    Stack Membro Participativo

    I want the dash.dcc.Dropdown to look like the dbc.DropdownMenu in the bootstrap site:

    [​IMG]

    This is my sample code:

    # -*- coding: utf-8 -*-
    from dash import Dash, dcc, html
    import dash_bootstrap_components as dbc

    dd = html.Div(
    dcc.Dropdown(
    options = [
    {'label': 'option 1', 'value': 1},
    {'label': 'option 2', 'value': 3},
    ],
    id = 'dd',
    ),
    **{"data-bs-theme": "dark"}
    # className="dash-bootstrap",
    )

    app = Dash(__name__,
    external_stylesheets=[
    dbc.themes.SLATE,
    ],
    )

    app.layout = dbc.Container(
    html.Div(
    [
    dbc.Row([
    dbc.Col(dd, width=3,),
    ],
    )
    ],
    className="dash-bootstrap",
    )
    )

    if __name__ == '__main__':
    app.run(debug=True)


    But what I get is this:

    [​IMG]

    What am I missing?

    Continue reading...

Compartilhe esta Página