Skip to content

CCV2 Embedded apps for concepts#1431

Merged
sfc-gh-dmatthews merged 25 commits intomainfrom
apps/custom-components-concepts
Mar 12, 2026
Merged

CCV2 Embedded apps for concepts#1431
sfc-gh-dmatthews merged 25 commits intomainfrom
apps/custom-components-concepts

Conversation

@sfc-gh-dmatthews
Copy link
Contributor

@sfc-gh-dmatthews sfc-gh-dmatthews commented Mar 7, 2026

📚 Context

This PR adds the source code for embedded examples in the Custom Components V2 docs, introduced later in this stack.

🧠 Description of Changes

Current:

No examples or documentation existed for the new components v2 API.

Revised:

Added complete component examples demonstrating various patterns and capabilities:

Basic Examples:

  • Simple "Hello World" component with inline HTML/CSS/JS
  • Simple button component with trigger values and callbacks
  • Basic counter with state management and external files

Interactive Components:

  • Interactive counter with both state and trigger values
  • Hold-to-confirm danger button with animations and cooldown
  • Radial menu selector with viewport-aware positioning
  • Stopwatch with complex state management and lap tracking

Display Components:

  • Radial dial gauge with smooth animations and color zones
  • Rich data handling example with DataFrames and base64 images

Component Architecture:

  • Modular file organization patterns (__init__.py, separate CSS/HTML/JS files)
  • State vs trigger value usage patterns
  • Callback function implementations
  • Data serialization examples (JSON, Arrow, base64)

Advanced Features:

  • CSS animations and transitions using Streamlit design tokens
  • Mobile-responsive touch event handling
  • Viewport boundary detection and positioning
  • Component cleanup and memory management
  • Session state integration patterns

💥 Impact

Size:

  • Small
  • Not small

🌐 References

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Copy link
Contributor Author

sfc-gh-dmatthews commented Mar 7, 2026

@sfc-gh-dmatthews sfc-gh-dmatthews marked this pull request as ready for review March 7, 2026 16:27
@sfc-gh-dmatthews sfc-gh-dmatthews changed the title Quickstart examples CCV2 Embedded apps for concepts Mar 7, 2026
@sfc-gh-dmatthews sfc-gh-dmatthews force-pushed the apps/custom-components-concepts branch from 301fdeb to c63a5b7 Compare March 8, 2026 20:06
@sfc-gh-dmatthews sfc-gh-dmatthews requested review from sfc-gh-bnisco and removed request for sfc-gh-kmcgrady March 11, 2026 19:12
Comment on lines +9 to +15
with open(component_dir / "button.css", "r") as f:
CSS = f.read()
with open(component_dir / "button.html", "r") as f:
HTML = f.read()
with open(component_dir / "button.js", "r") as f:
JS = f.read()
return HTML, CSS, JS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: I am a little worried about using this as a pattern in our docs. While it is valid, there are some drawbacks. One notable drawback I've seen is that it doesn't always detect a file change when the underlying files change, so refreshing the page leads to a stale component. One would have to restart the streamlit server in order for the changes to be picked up.

While it might be a bit uglier, putting the file content in Python strings might be better overall.

We have considered expanding the API in Streamlit to allow for Paths to be passed directly to the html/css/js arguments of st.components.v2.component(), but haven't implemented that yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be delightful if we could support local paths for non-packaged components. That would definitley clean up the docs for me.

Copy link
Contributor Author

sfc-gh-dmatthews commented Mar 12, 2026

Merge activity

  • Mar 12, 8:08 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 12, 8:09 PM UTC: @sfc-gh-dmatthews merged this pull request with Graphite.

@sfc-gh-dmatthews sfc-gh-dmatthews merged commit 66d2635 into main Mar 12, 2026
5 checks passed
@sfc-gh-dmatthews sfc-gh-dmatthews deleted the apps/custom-components-concepts branch March 12, 2026 20:09
@sfc-gh-dmatthews sfc-gh-dmatthews restored the apps/custom-components-concepts branch March 12, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants