在streamlit中使用shadcn-ui组件
<img width="1453" alt="streamlit-shadcn" src="https://github.com/ObservedObserver/streamlit-shadcn-ui/assets/22167673/75620347-9e9c-454c-a7ce-381d7464c519">pip install streamlit-shadcn-ui
示例:
import streamlit_shadcn_ui as ui trigger_btn = ui.button(text="触发按钮", key="trigger_btn") ui.alert_dialog(show=trigger_btn, title="警告对话框", description="这是一个警告对话框", confirm_label="确定", cancel_label="取消", key="alert_dialog1")
目前正在测试一个新组件,它将允许您嵌套所有streamlit-shadcn-ui组件。 它不会将每个组件作为iframe中的独立streamlit自定义组件处理,而是将组件结构解析为数据,并在一个iframe中一次性渲染所有组件。
示例(在线演示):
with ui.card(key="card1"): with ui.card(key="card2"): ui.element("input", key="card2_input") ui.element("button", key="card2_btn", text="嵌套提交", variant="outline") ui.element("button", key="card1_btn", text="你好世界")
scripts
文件夹中有几个脚本可以帮助您开发此项目。
# 用于本地开发 ./scripts/frontend.sh # 前端开发服务器 ./scripts/dev.sh # streamlit开发服务器
本仓库遵循streamlit自定义组件结构。
./streamlit_shadcn_ui
是Python包
./streamlit_shadcn_ui/components
是前端monorepo
./streamlit_shadcn_ui/components/packages/frontend
是自定义组件集合。./streamlit_shadcn_ui/components/packages/streamlit-components-lib
是为React 18打补丁的streamlit-components-lib(目前只改变了react/react-dom版本)。./streamlit_shadcn_ui/py_components
是组件的Python级API。本仓库采用MIT许可证。详情请参阅LICENSE。
streamlit_shadcn_ui/components/packages/streamlit-components-lib
遵循其原始的Apache-2.0许可证。这是streamlit-components-lib在React 18中的临时补丁。
AI辅助编程,代码自动修 复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI小说写作助手,一站式润色、改写、扩写
蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。