Skip to main content

Streamlit component that integrates TLDraw, a powerful whiteboard and drawing tool directly to your streamlit apps

Project description

Streamlit tldraw

A Streamlit component that integrates the tldraw whiteboard library for creating diagrams, system designs, ER diagrams and more. This component uses the latest tldraw v2 API.

Streamlit tldraw Demo

Installation

pip install streamlit-tldraw

Quick Start

import streamlit as st
from streamlit_tldraw import st_tldraw

st.title("tldraw in Streamlit")

# Basic usage
result = st_tldraw(key="my_canvas")

# Display the result
if result:
    st.write("Canvas data:", result)

Usage

import streamlit as st
from streamlit_tldraw import st_tldraw

st.title("tldraw in Streamlit")

# Basic usage
result = st_tldraw(key="my_canvas")

# Advanced usage with options
result = st_tldraw(
    key="advanced_canvas",
    width=800,
    height=600,
    read_only=False,
    dark_mode=True,
    show_ui=True,
)

# Display the result
if result:
    st.write("Canvas data:", result)

Parameters

  • key (str, optional): A unique key for the component instance.
  • width (int, optional): The width of the canvas in pixels. Defaults to container width.
  • height (int, default 600): The height of the canvas in pixels.
  • read_only (bool, default False): Whether the canvas should be in read-only mode.
  • dark_mode (bool, default False): Whether to use dark mode.
  • show_ui (bool, default True): Whether to show the UI elements (toolbar, menu).
  • initial_data (dict, optional): Initial data to load into the canvas.

Return Value

The component returns a dictionary containing:

  • snapshot: The current state of the canvas
  • type: The type of event ('mounted' or 'document_change')

Features

  • Infinite Canvas: Create diagrams on an infinite canvas with pan and zoom.
  • Rich Tools: Draw shapes, add text, create arrows, and more.
  • Styling Options: Customize colors, line styles, and text formatting.
  • Real-time Data: All changes are sent back to Streamlit in real-time.
  • Dark Mode: Switch between light and dark themes.
  • Read-only Mode: Display diagrams without allowing edits.
  • UI Visibility Control: Show or hide the toolbar and menu.
  • Initial Data Loading: Load pre-existing diagrams.

What's New in v0.1.3

  • Fixed issue with updates not being sent back to Streamlit
  • Improved dark mode implementation
  • Enhanced read-only mode functionality
  • Fixed UI visibility toggle
  • Better error handling and debugging
  • Improved initial data loading

Examples

Check out the included example.py for a full demonstration:

streamlit run path/to/streamlit_tldraw/example.py

Or try the simple test.py:

streamlit run path/to/streamlit_tldraw/test.py

Development

For development instructions, see DEV_README.md.

License

MIT

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

streamlit_tldraw-0.1.3.tar.gz (13.3 MB view details)

Uploaded Source

Built Distribution

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

streamlit_tldraw-0.1.3-py3-none-any.whl (15.3 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_tldraw-0.1.3.tar.gz.

File metadata

  • Download URL: streamlit_tldraw-0.1.3.tar.gz
  • Upload date:
  • Size: 13.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for streamlit_tldraw-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f7ee4d918f7e949f729c36f23d67337205be507bc8199879f7b7a4657481a649
MD5 bb30cb88d4af072ad2ac6b96c27e7b4d
BLAKE2b-256 8872b976d1f99b4acf252f85758aa3715fb8959d19b6fbeb8c92fa712bb07ad1

See more details on using hashes here.

File details

Details for the file streamlit_tldraw-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_tldraw-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dfd40ed6c7269fc217a8fac96846dd1bfb990cbf257c8cf4cc5c29215a701ce1
MD5 63da4ce46868e246d648ad7414995485
BLAKE2b-256 e3211935c5b42cce31678022c0d5282a94fc4b3d2c3e1d390a676b2a16e35e62

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