Skip to main content

Using shadcn components in Streamlit

Project description

streamlit-shadcn-ui :construction:

streamlit-shadcn-ui is in early development, the updates is shipped frequently. A relative stable will be launched after 11/27 2023. Follow the developer on twitter for updates: Follow ob12er

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
  • table
  • input
  • slider
  • textarea
  • switch
  • radio_group
  • alert_dialog
  • hover_card
  • badges
  • link_button

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.

POC:

with ui.element("card", key="base_ele") as card:
    with ui.element("card", key="base_ele2") as card2:
        card2.add_child(ui.element("input", key="nst2_input"))
        card2.add_child(ui.element("button", key="nst2_btn", text="Nest Submmit", variant="outline"))
    card.add_child(card2)
    card.add_child(ui.element("button", key="nst_btn", text="Hello World"))
POC example

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.12.tar.gz (173.6 kB view hashes)

Uploaded Source

Built Distribution

streamlit_shadcn_ui-0.1.12-py3-none-any.whl (180.3 kB view hashes)

Uploaded Python 3

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