{"id":1441,"library":"dash","title":"Dash","description":"Dash is a Python framework for building analytical web applications. Developed by Plotly, it allows users to create interactive dashboards and data visualization tools entirely in Python, without requiring JavaScript or web development expertise. It is currently at version 4.1.0 and typically releases minor versions and release candidates regularly, leading up to major version updates.","status":"active","version":"4.1.0","language":"en","source_language":"en","source_url":"https://github.com/plotly/dash","tags":["web","framework","dashboard","plotly","react","data-visualization"],"install":[{"cmd":"pip install dash","lang":"bash","label":"Base installation"},{"cmd":"pip install dash[fastapi]","lang":"bash","label":"With FastAPI backend"},{"cmd":"pip install dash[quart]","lang":"bash","label":"With Quart backend"}],"dependencies":[{"reason":"Default web server backend for Dash applications.","package":"flask","optional":false},{"reason":"Alternative web server backend (requires `dash[fastapi]` install).","package":"fastapi","optional":true},{"reason":"Alternative web server backend (requires `dash[quart]` install).","package":"quart","optional":true}],"imports":[{"symbol":"Dash","correct":"from dash import Dash"},{"symbol":"html","correct":"from dash import html"},{"symbol":"dcc","correct":"from dash import dcc"},{"note":"The `dash.dependencies` module is deprecated. Since Dash 2.0, `Input`, `Output`, `State`, and the `callback` decorator are imported directly from the `dash` package.","wrong":"from dash.dependencies import Input, Output, State","symbol":"Input, Output, State, callback","correct":"from dash import Input, Output, State, callback"}],"quickstart":{"code":"import os\nfrom dash import Dash, html, dcc, Input, Output, State, callback\n\n# Initialize the Dash app\n# For deployment, consider setting up a robust WSGI server (e.g., Gunicorn)\n# and handling config via environment variables.\napp = Dash(__name__)\n\napp.layout = html.Div([\n    html.H1(\"Dash Quickstart App\"),\n    html.Button(\"Click Me\", id=\"my-button\", n_clicks=0),\n    html.Div(id=\"my-output\", children=\"No clicks yet.\")\n])\n\n# Define a callback to update the output based on button clicks\n@callback(\n    Output(\"my-output\", \"children\"),\n    Input(\"my-button\", \"n_clicks\"),\n    State(\"my-output\", \"children\"),\n    prevent_initial_call=True # Prevents the callback from firing on initial load\n)\ndef update_output(n_clicks, current_text):\n    if n_clicks is None:\n        # This branch might be reached if prevent_initial_call=False\n        return \"No clicks yet.\"\n    return f\"Button has been clicked {n_clicks} times!\"\n\n# Run the app\nif __name__ == \"__main__\":\n    # In production, set debug=False and use a production-ready WSGI server\n    app.run_server(debug=True)","lang":"python","description":"This quickstart demonstrates a basic Dash application with a single button and a division that updates its text when the button is clicked. It uses modern Dash imports and the `@callback` decorator, including `prevent_initial_call` to avoid errors on initial page load."},"warnings":[{"fix":"Change `from dash.dependencies import Input, Output, State` to `from dash import Input, Output, State, callback`.","message":"The `dash.dependencies` module for importing `Input`, `Output`, `State` is deprecated. These symbols, along with the `callback` decorator, should now be imported directly from the `dash` package.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Consult the official Dash documentation and component property references for updated usage. Thoroughly test existing applications after upgrading to v4.0.0 or later.","message":"Dash Core Components (DCC) underwent a significant redesign in Dash v4.0.0. This might introduce breaking changes to component properties, styling, or internal structure for applications upgrading from older versions.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Set `prevent_initial_call=True` in your `@app.callback` decorator to prevent it from running on initial page load. Alternatively, implement checks within your callback function for `None` or initial states of inputs.","message":"By default, Dash callbacks fire immediately upon application load. This can lead to errors if input components have not yet been rendered or populated with initial values (e.g., `None` where a string or number is expected).","severity":"gotcha","affected_versions":"All"},{"fix":"Choose the correct parameter based on your needs. Use `backend` if you want Dash to manage the server instance (e.g., `app = Dash(__name__, backend='fastapi')`). Use `server` if integrating Dash into an existing, running web framework application (e.g., `app = Dash(server=my_fastapi_app)`).","message":"With the introduction of multi-backend support in Dash 4.1.0, there are two distinct ways to specify a backend server: `Dash(backend=\"flask\"| \"fastapi\" | \"quart\")` or `Dash(server=existing_server_instance)`. Using `backend` creates a new server instance, while `server` attaches Dash to an *already existing* Flask/FastAPI/Quart application instance.","severity":"gotcha","affected_versions":">=4.1.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}