Add anywidget extra for rendering anywidget-compatible widgets - #314
Add anywidget extra for rendering anywidget-compatible widgets#314lukasmasuch wants to merge 5 commits into
Conversation
Introduces a new `anywidget` extra that wraps any anywidget-compatible widget and renders it in Streamlit with full bidirectional interactivity. Uses a React-based CC v2 implementation for stable state management. Features: - Support for inline ESM, file-based ESM, and pre-bundled widgets - Bidirectional trait synchronization (Python ↔ JavaScript) - model.send() support for custom messaging - Streamlit theming integration via CSS variables Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Deploy Preview for streamlit-extras-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new anywidget optional extra to streamlit-extras, including a Streamlit Custom Component v2 (React) frontend and a Python wrapper to render anywidget-compatible widgets with bidirectional state sync.
Changes:
- Add
anywidgetas an installable optional dependency extra (pip install streamlit-extras[anywidget]). - Introduce a new CCv2 React component (
anywidget/frontend) plus the Python integration (streamlit_extras.anywidget). - Add a demo app showcasing inline widgets and an external anywidget (
drawdata).
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Locks new Python deps for the anywidget extra and its transitive requirements. |
pyproject.toml |
Declares the anywidget optional dependency group and updates Ruff per-file ignores. |
src/streamlit_extras/pyproject.toml |
Registers the new CCv2 component asset directory for anywidget. |
src/streamlit_extras/anywidget/__init__.py |
Core Python API (anywidget(...)) and trait/message synchronization logic. |
src/streamlit_extras/anywidget/example_app.py |
End-to-end demo app for interactive validation. |
src/streamlit_extras/anywidget/frontend/package.json |
Frontend build/tooling dependencies and scripts (Vite + React). |
src/streamlit_extras/anywidget/frontend/package-lock.json |
Locked frontend dependency graph for reproducible builds. |
src/streamlit_extras/anywidget/frontend/tsconfig.json |
TypeScript configuration for the React component. |
src/streamlit_extras/anywidget/frontend/vite.config.ts |
Vite library-mode build config producing index-*.js bundles. |
src/streamlit_extras/anywidget/frontend/src/index.tsx |
CCv2 renderer entrypoint mounting the React root per component instance. |
src/streamlit_extras/anywidget/frontend/src/AnywidgetContainer.tsx |
Runtime widget loader (blob ESM import), model adapter, trait + message sync. |
src/streamlit_extras/AGENTS.md |
Documents the new extra in the repo’s implementation guide table. |
Files not reviewed (1)
- src/streamlit_extras/anywidget/frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Addressed all review feedback in commit 3447606: Comment #1 (Accessibility): Added Comment #2 (Click state): Replaced boolean Comment #3 (Return value): Now tracking click count changes in Comment #4 (Validate on_click): Added validation that raises Comment #5 (Validate height): Added validation that raises |
|
Wow, the drawer example is pretty sick.
|
Summary
Adds a new
anywidgetextra that enables rendering any anywidget-compatible widget in Streamlit with full bidirectional interactivity. This uses a React-based Custom Components v2 implementation for stable state management.Features:
model.send()support for custom messagingTest plan
uv run streamlit run src/streamlit_extras/anywidget/example_app.py