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.

Installation

pip install streamlit-tldraw

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,
    initial_data=None  # You can provide initial diagram data here
)

# 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.

Examples

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

streamlit run path/to/streamlit_tldraw/example.py

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.1.tar.gz (7.4 kB 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.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_tldraw-0.1.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for streamlit_tldraw-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f8fbb7d3b39b5d67542a1e447d1a252697f2ec9fac190381d3cfba9d709854de
MD5 29a8beb7b53c060618f9ba987f893f8f
BLAKE2b-256 de007ee094ae2b7439b9c4a422d9d9ca152f20a7cbddd7cd8561795f40ed8d8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_tldraw-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7fa18dc93ee1d15941ba4be352ddcd96f2b9922b7f97a85b291a679a97bf7ca1
MD5 9315d8ac4acc20d4e58698db1415890e
BLAKE2b-256 4a6ae4185065d540455cf41226362bf9648fa299476863de48d1098ff064f534

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