Dash Core Components
Dash Core Components (dcc) is a suite of interactive user interface components for building analytical web applications with Dash. It provides essential UI elements like dropdowns, sliders, graphs, and input fields. As of version 2.0.0, it is integrated directly into the main `dash` library, simplifying imports. Maintained by Plotly, its release cadence is tied to that of the overarching Dash framework, seeing significant updates with major Dash versions.
Warnings
- breaking Dash 2.0.0 introduced a breaking change to import statements. Previously, `dash_core_components` was imported as a separate package. Now, `dcc` is imported directly from the `dash` namespace.
- breaking Dash 2.0.0 (and thus dash-core-components 2.0.0) officially dropped support for Python 2. Applications using older Python versions will fail.
- gotcha When defining callbacks in Dash 2.0.0+, if you are using `State` arguments in your `@app.callback` decorator, any `Input` arguments must now explicitly be named with `input=` (e.g., `Input(component_id='my-input', component_property='value')`). Previously, implicit naming was sometimes tolerated.
- gotcha Dash Core Components provide functionality but minimal default styling. For aesthetically pleasing and consistent layouts, it's highly recommended to use external CSS stylesheets or integrate with a component library like `dash-bootstrap-components`.
- gotcha Callbacks that perform long-running operations can cause the UI to appear frozen. Use `dcc.Loading` to wrap components that are targets of such callbacks to provide visual feedback to the user.
Install
-
pip install dash
Imports
- dcc
from dash import dcc
Quickstart
from dash import Dash, html, dcc
app = Dash(__name__)
app.layout = html.Div([
html.H1("My Dash App with Core Components"),
dcc.Dropdown(
['New York City', 'Montréal', 'San Francisco'],
'Montréal',
id='city-dropdown'
),
html.Div(id='output-container')
])
# Callbacks would typically be added here for interactivity
if __name__ == '__main__':
app.run_server(debug=True)