or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

asset-management.mdbackground-callbacks.mdcallback-system.mdcomponent-libraries.mdcore-application.mdindex.mdmulti-page-apps.mdspecial-values.md
tile.json

tessl/pypi-dash

Python web application framework for building reactive analytical web apps without JavaScript

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/dash@3.2.x

To install, run

npx @tessl/cli install tessl/pypi-dash@3.2.0

index.mddocs/

Dash

Dash is a Python web application framework for building reactive analytical web applications. Built on top of Plotly.js, React, and Flask, Dash enables data scientists and analysts to build interactive web apps using pure Python without requiring JavaScript knowledge.

Package Information

  • Package Name: dash
  • Language: Python
  • Installation: pip install dash

Core Imports

import dash
from dash import Dash, dcc, html, dash_table, Input, Output, State, callback

Common patterns:

from dash import Dash, html, dcc, callback, Input, Output, State

Basic Usage

from dash import Dash, html, dcc, callback, Input, Output
import plotly.express as px

# Initialize the app
app = Dash(__name__)

# Define the layout
app.layout = html.Div([
    html.H1("Hello Dash"),
    html.Div("Select a value:"),
    dcc.Dropdown(
        id='dropdown',
        options=[
            {'label': 'New York City', 'value': 'NYC'},
            {'label': 'Montreal', 'value': 'MTL'},
            {'label': 'San Francisco', 'value': 'SF'}
        ],
        value='NYC'
    ),
    html.Div(id='output-container')
])

# Define callback
@callback(
    Output('output-container', 'children'),
    Input('dropdown', 'value')
)
def update_output(value):
    return f'You have selected {value}'

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

Architecture

Dash follows a reactive programming model with these key components:

  • Dash App: Central application instance managing server, layout, and callbacks
  • Layout System: Hierarchical component tree defining UI structure using dcc, html, and custom components
  • Callback System: Reactive functions that update components based on user interactions
  • Component Libraries: Rich ecosystem of interactive components (graphs, inputs, tables, etc.)
  • Server Integration: Built on Flask for production deployment and extensibility

Capabilities

Core Application

Main Dash application class for creating and configuring web applications with layout management, callback registration, and server integration.

class Dash:
    def __init__(
        self,
        name: str = None,
        server: Any = None,
        assets_folder: str = 'assets',
        pages_folder: str = 'pages',
        use_pages: bool = None,
        assets_url_path: str = '/assets/',
        assets_ignore: str = '',
        external_scripts: List[Union[str, Dict]] = None,
        external_stylesheets: List[Union[str, Dict]] = None,
        suppress_callback_exceptions: bool = None,
        prevent_initial_callbacks: bool = None,
        show_undo_redo: bool = False,
        plugins: List = None,
        title: str = 'Dash',
        update_title: str = 'Updating...',
        **kwargs
    ): ...
    
    def run(self, debug: bool = None, port: int = 8050, host: str = '127.0.0.1', **kwargs): ...
    def callback(self, *args, **kwargs): ...
    def clientside_callback(self, clientside_function, output, inputs, state=None, **kwargs): ...

Core Application

Callback System

Reactive programming system that connects user interactions to data updates through Input/Output dependencies and callback functions.

class Input:
    def __init__(self, component_id: Union[str, Dict], component_property: str): ...

class Output:
    def __init__(self, component_id: Union[str, Dict], component_property: str): ...

class State:
    def __init__(self, component_id: Union[str, Dict], component_property: str): ...

class ClientsideFunction:
    def __init__(self, namespace: str, function_name: str): ...

def callback(*args, **kwargs): ...
def clientside_callback(clientside_function, output, inputs, state=None, **kwargs): ...

# Wildcard patterns
MATCH: Any  # Match any ID in pattern-matching callbacks
ALL: Any    # Match all IDs in pattern-matching callbacks
ALLSMALLER: Any  # Match all smaller indices in pattern-matching callbacks

Callback System

Component Libraries

Comprehensive component ecosystem including core components (dcc), HTML elements (html), and data tables (dash_table).

# Dash Core Components (dcc)
class Graph(Component): ...
class Dropdown(Component): ...
class Slider(Component): ...
class Input(Component): ...
class Store(Component): ...
class Location(Component): ...
class Link(Component): ...

# Dash HTML Components (html)
class Div(Component): ...
class H1(Component): ...
class Button(Component): ...
class A(Component): ...
class P(Component): ...

# Dash DataTable
class DataTable(Component): ...

Component Libraries

Multi-Page Applications

Built-in support for single-page application (SPA) navigation with automatic routing, page registration, and SEO optimization.

def register_page(
    module: str = None,
    path: str = None,
    path_template: str = None,
    name: str = None,
    order: Union[int, float] = None,
    title: str = None,
    description: str = None,
    image: str = None,
    redirect_from: List[str] = None,
    layout: Any = None,
    **kwargs
): ...

page_registry: Dict[str, Any]  # Registry of all registered pages
page_container: Component      # Container component for page content

Multi-Page Applications

Special Values and Control

Special values and utilities for controlling callback execution and component updates.

class NoUpdate:
    """Sentinel value to prevent component updates."""
    pass

no_update: NoUpdate  # Alias for NoUpdate()

class PreventUpdate(Exception):
    """Exception to prevent callback execution."""
    pass

class Patch:
    """Partial updates for lists and dictionaries."""
    def append(self, item): ...
    def prepend(self, item): ...
    def insert(self, index: int, item): ...
    def remove(self, item): ...
    def clear(self): ...

Special Values and Control

Background Callbacks

Asynchronous callback processing for long-running operations with progress reporting and caching support.

class CeleryManager:
    def __init__(self, celery_app): ...

class DiskcacheManager:
    def __init__(self, cache_by: str = "session", cache: Any = None): ...

# Background callback decorator
@callback(
    background=True,
    manager=CeleryManager(celery_app),
    running=[(Output("loading", "children"), "Running...")],
    progress=[Output("progress", "value"), Output("progress", "max")],
    progress_default=[0, 100]
)
def long_running_callback(*args): ...

Background Callbacks

Asset Management

Static asset handling including CSS, JavaScript, images, and external resources with hot reloading and fingerprinting.

def get_asset_url(path: str) -> str:
    """Get URL for asset file."""
    ...

def get_relative_path(path: str) -> str:
    """Get relative path from request."""
    ...

def strip_relative_path(path: str) -> str:
    """Strip relative path prefix."""
    ...

Asset Management

Types

# Core types
Component = Any                           # Base component class
ComponentIdType = Union[str, Dict, Component]  # Component identifier
LayoutType = Union[Component, List, Dict, str, int, float]  # Layout content

# Callback types
CallbackContext = Any                     # Callback execution context
CallbackFunction = Callable[..., Any]     # Callback function signature
DependencyList = List[Union[Input, Output, State]]  # Callback dependencies

# App configuration
ServerType = Any                          # Flask server instance
AssetList = List[Union[str, Dict[str, str]]]  # External assets
PluginList = List[Any]                    # Plugin instances

# Multi-page types
PageConfig = Dict[str, Any]               # Page configuration
PageRegistry = Dict[str, PageConfig]      # Page registry