Dash Bootstrap Components

2.0.4 · active · verified Fri Apr 10

Dash Bootstrap Components (dbc) provides a set of Bootstrap-themed components for building interactive Plotly Dash applications. It brings popular UI elements like cards, modals, navbars, and layouts, styled with Bootstrap 5. The current stable version is 2.0.4, with a regular cadence of patch releases addressing bug fixes and minor improvements, typically every few weeks.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic Dash application using Dash Bootstrap Components. It includes a Bootstrap-styled container, an alert, a button, and an input field with a callback, all leveraging dbc's theming and components. It's crucial to include `external_stylesheets=[dbc.themes.BOOTSTRAP]` when initializing the Dash app for correct styling.

from dash import Dash, html, dcc
import dash_bootstrap_components as dbc

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

app.layout = html.Div([
    dbc.Container([
        html.H1("Hello dbc!"),
        dbc.Alert("This is a primary alert", color="primary"),
        dbc.Button("Click Me", color="success", className="me-2"),
        dcc.Input(id="my-input", value="Hello world", type="text"),
        html.Div(id="my-output")
    ])
])

@app.callback(
    Output("my-output", "children"),
    Input("my-input", "value"),
)
def update_output(input_value):
    return f"You entered: {input_value}"

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

view raw JSON →