Skip to main content

Using shadcn components in Streamlit

Project description

streamlit-shadcn-ui :construction:

PyPI - Version PyPI - Downloads Streamlit App

Using shadcn-ui components in streamlit

streamlit-shadcn

Installation

pip install streamlit-shadcn-ui

example:

import streamlit_shadcn_ui as ui
trigger_btn = ui.button(text="Trigger Button", key="trigger_btn")

ui.alert_dialog(show=trigger_btn, title="Alert Dialog", description="This is an alert dialog", confirm_label="OK", cancel_label="Cancel", key="alert_dialog1")

Components

Check docs and compoenent examples in Streamlit App

  • button
  • checkbox
  • select
  • tabs
  • card
  • avatar
  • date_picker
  • date_range_picker (date_picker with mode="range")
  • table
  • input
  • slider
  • textarea
  • switch
  • radio_group
  • alert_dialog
  • hover_card
  • badges
  • link_button

streamlit card

streamlit date picker

streamlit select

One more thing

There is a new component in testing, it will allows you to nest all streamlit-shadcn-ui components together. It will not treat each component as an independent streamlit custom component in iframe, but parse the component structure as data and render them all at once in one iframe.

example (live demo):

with ui.card(key="card1"):
    with ui.card(key="card2"):
        ui.element("input", key="card2_input")
        ui.element("button", key="card2_btn", text="Nest Submmit", variant="outline")
    ui.element("button", key="card1_btn", text="Hello World")

streamlit react_component

Development Guide

There are several scripts in scripts folder to help you develop this project.

# For local development
./scripts/frontend.sh # frontend dev server
./scripts/dev.sh # streamlit dev server

This repo follows the streamlit custom component structure.

  • ./streamlit_shadcn_ui is the python package
    • ./streamlit_shadcn_ui/components is the frontend mono repo
      • ./streamlit_shadcn_ui/components/packages/frontend is the custom components collection.
      • ./streamlit_shadcn_ui/components/packages/streamlit-components-lib is a patch of streamlit-components-lib for react 18 (For now, only the react/react-dom version is changed).
    • ./streamlit_shadcn_ui/py_components is the python level API for components.

Reference

License

This repo is under MIT license. See LICENSE for details. streamlit_shadcn_ui/components/packages/streamlit-components-lib is under its original Apache-2.0 license. It is a temporal patch for streamlit-components-lib in react 18.

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-shadcn-ui-0.1.18.tar.gz (262.1 kB view details)

Uploaded Source

Built Distribution

streamlit_shadcn_ui-0.1.18-py3-none-any.whl (276.4 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-shadcn-ui-0.1.18.tar.gz.

File metadata

  • Download URL: streamlit-shadcn-ui-0.1.18.tar.gz
  • Upload date:
  • Size: 262.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for streamlit-shadcn-ui-0.1.18.tar.gz
Algorithm Hash digest
SHA256 37a4b95869cdbd285310e7da0cc6130670b055a4bb48a3442f228a26e71b82d6
MD5 58ce70ee77177a0878925d607fe5f5cb
BLAKE2b-256 0a131188fad0a7a4c54cc3d2e56a7723f8a4155006a4617ab73ae9f7106c765a

See more details on using hashes here.

File details

Details for the file streamlit_shadcn_ui-0.1.18-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_shadcn_ui-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 6e1728f0f1d24508a17fc030ac0216a35077980e80585a0ced406ece822c0168
MD5 693ee45054ed85a6cee5668a95ab10f7
BLAKE2b-256 12344ec3e3569a36cca3f6f0c8a25e9344b6acce9d21308552f17531eec5d034

See more details on using hashes here.

Supported by

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