Skip to main content

excalidraw interactive drawing and freeform component for dash.

Project description

Dash Excalidraw

PyPI version Downloads

A Dash component that wraps the powerful Excalidraw drawing and diagramming tool, providing a customizable canvas for creating beautiful hand-drawn like diagrams, wireframes, and sketches directly in your Dash applications.

Docs

https://pip-install-python.com/pip/dash_excalidraw

Full Tutorial Video on YouTube

Dash Excalidraw Demo

Features

The Dash Excalidraw component inherits all the powerful features of the Excalidraw editor:

  • Free & open-source
  • Infinite, canvas-based whiteboard
  • Hand-drawn like style
  • Dark mode support
  • Highly customizable
  • Image support
  • Shape libraries support
  • Localization (i18n) support
  • Export to PNG, SVG & clipboard
  • Open format - export drawings as .excalidraw JSON file
  • Rich toolset - rectangle, circle, diamond, arrow, line, free-draw, eraser & more
  • Arrow-binding & labeled arrows
  • Undo / Redo support
  • Zoom and panning support
  • And many more...

Installation

pip install dash-excalidraw==0.0.4

Quick Start

Here's a simple example to get you started:

import dash_excalidraw
from dash import Dash, html
import dash_mantine_components as dmc

app = Dash(__name__)

app.layout = dmc.MantineProvider([
    dmc.Container([
        dmc.Title("Dash Excalidraw Demo", order=1),
        dash_excalidraw.DashExcalidraw(
            id='excalidraw',
            width='100%',
            height='600px',
            initialData={"elements": [], "appState": {}},
            theme="light"
        )
    ])
])

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

Props & Options

Option Default Type Description
id None string The ID used to identify this component in Dash callbacks
width '100%' string The width of the Excalidraw component
height '400px' string The height of the Excalidraw component
initialData { elements: [], appState: {} } object Initial data to load into the component
theme 'light' 'light' | 'dark' The theme of the component
viewModeEnabled false boolean Enables view-only mode
zenModeEnabled false boolean Enables zen mode
gridModeEnabled false boolean Enables grid mode
isCollaborating false boolean Indicates if the component is in collaboration mode

View full props documentation

Callback Example

from dash import callback, Input, Output
import json

@callback(
    Output('output', 'children'),
    Input('excalidraw', 'serializedData'),
)
def display_output(serializedData):
    if not serializedData:
        return 'No elements drawn yet'
    
    data = json.loads(serializedData)
    return f'Number of elements: {len(data["elements"])}'

Props Documentation

Core Props

Click to expand
Prop Type Default Description
id string None Component identifier
width string '100%' Component width
height string '400px' Component height
initialData object { elements: [], appState: {} } Initial scene data
elements array [] Current scene elements
appState object {} Application state
files object {} Associated files
serializedData string '' Serialized scene data

Interactive Features

Click to expand
Prop Type Default Description
excalidrawAPI function null Access Excalidraw API
onPointerUpdate function null Pointer update callback
onPointerDown function null Pointer down callback
onScrollChange function null Scroll change callback
onPaste function null Paste event callback
onLibraryChange function null Library change callback
onLinkOpen function null Link open callback

UI Customization

Click to expand
Prop Type Default Description
theme string 'light' UI theme
langCode string 'en' Localization code
renderTopRightUI function null Custom top-right UI
renderCustomStats function null Custom stats display
UIOptions object {} UI customization options

Advanced Example

import dash_excalidraw
from dash import Dash, html, callback, Input, Output
import dash_mantine_components as dmc
import json

app = Dash(__name__)

app.layout = dmc.MantineProvider([
    dmc.Container([
        dmc.Title("Dash Excalidraw Demo", order=1, align="center", mb="lg"),
        dash_excalidraw.DashExcalidraw(
            id='excalidraw',
            width='100%',
            height='600px',
            initialData={
                "elements": [], 
                "appState": {
                    "viewBackgroundColor": "#ffffff",
                    "gridSize": 20
                }
            },
            theme="light",
            viewModeEnabled=False,
            zenModeEnabled=False,
            gridModeEnabled=True
        ),
        html.Div(id='output')
    ], size="xl", pt="md")
], withGlobalStyles=True)

@callback(
    Output('output', 'children'),
    Input('excalidraw', 'serializedData')
)
def display_output(serializedData):
    if not serializedData:
        return 'No elements drawn yet'
    
    data = json.loads(serializedData)
    return f'Number of elements: {len(data["elements"])}'

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

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash_excalidraw-0.0.4.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_excalidraw-0.0.4-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file dash_excalidraw-0.0.4.tar.gz.

File metadata

  • Download URL: dash_excalidraw-0.0.4.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for dash_excalidraw-0.0.4.tar.gz
Algorithm Hash digest
SHA256 495ae3a0e3dec76a20238288ee417480210602ee6d614e2df39b048af22deab9
MD5 257d7ccb4acdd4922a4c4a515a12072c
BLAKE2b-256 a8ce198653365490f89f548798c347f8f8c4fea981957f23103c9502b98f070f

See more details on using hashes here.

File details

Details for the file dash_excalidraw-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for dash_excalidraw-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 46419b0a3f67b116443cb66f7f4db01ea52ea9df49e04b5bad8fe7f3a4d6ea37
MD5 6e87f8ab39675e3faf80f3d041001b4f
BLAKE2b-256 1e5e19de913a08b2b36b02dd0a5a7fa13ddc3f36d5ac716b8778efbfb423c4c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page