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.2.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.2-py3-none-any.whl (15.3 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_tldraw-0.1.2.tar.gz
  • Upload date:
  • Size: 13.3 MB
  • 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.2.tar.gz
Algorithm Hash digest
SHA256 476579a654211551c70612cd6985b747fa4c6f3dcf87906b5cda895901a4cb97
MD5 26ffff7b58e60a727d3846340e0ca070
BLAKE2b-256 835ed723e63737626b006581e5c2033fe05efd09b858fd39ddd225d7f8bfa445

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_tldraw-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 13b9d581f0153688b0ebc8d1d78440cc7a295ebf7a4a7c76c952e465e02ea702
MD5 109f7bc56a032374cae2e8e349793c40
BLAKE2b-256 4cf55c77a42ab7359954dc684ab2f821c691f97a19a9c9520b38beac52955b4b

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