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
  • accordion
  • alert
  • aspect_ratio
  • calendar
  • carousel
  • checkbox
  • collapsible
  • command
  • dialog
  • dropdown_menu
  • input-OTP
  • metric_card
  • pagination
  • popover
  • progress
  • radio_group
  • resizable
  • scroll_area
  • separator
  • skeleton
  • toggle
  • toggle_group

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.19.tar.gz (330.5 kB view details)

Uploaded Source

Built Distribution

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

streamlit_shadcn_ui-0.1.19-py3-none-any.whl (360.6 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_shadcn_ui-0.1.19.tar.gz.

File metadata

  • Download URL: streamlit_shadcn_ui-0.1.19.tar.gz
  • Upload date:
  • Size: 330.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for streamlit_shadcn_ui-0.1.19.tar.gz
Algorithm Hash digest
SHA256 70023d343c74a9542180092769ba26841a9248cdfe1a13b2415bfc6710f9b1bd
MD5 56e7c49d88096d81ec29ec8bb2ac1837
BLAKE2b-256 9844988e29d4853d0420e7c378393218a92bd897dbb399a7380102f44d821535

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_shadcn_ui-0.1.19-py3-none-any.whl
Algorithm Hash digest
SHA256 73466ba1cc690794d41f5b67fd271c27ed8f78c6a3437d9df90a5409816299ec
MD5 bc2720edfdd7f365c5a6d66e1160aec9
BLAKE2b-256 37251f5d992affc461a72f339876fbd3a1cde6b96aa3df08405bd3bd758f1f35

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