Skip to content

Conversation

@sfc-gh-bnisco
Copy link
Collaborator

@sfc-gh-bnisco sfc-gh-bnisco commented Jan 6, 2026

Describe your changes

Move isolate_styles parameter from component mount-time to component registration time. This change makes the API more intuitive by setting style isolation when defining a component rather than when mounting it.

Key changes:

  • Added isolate_styles parameter to component() function
  • Removed isolate_styles parameter from the component mount function
  • Added backward compatibility to silently ignore isolate_styles if passed at mount time
  • Updated documentation and type hints to reflect the new API
  • Removed isolate_styles=True from component calls in e2e tests

Testing Plan

  • Unit Tests: Added a new test test_component_mount_ignores_isolate_styles_kwarg() to verify that passing isolate_styles at mount time is properly handled for backward compatibility
  • E2E tests continue to pass with the updated parameter location

Contribution License Agreement

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

@snyk-io
Copy link
Contributor

snyk-io bot commented Jan 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sfc-gh-bnisco sfc-gh-bnisco added the change:feature PR contains new feature or enhancement implementation label Jan 6, 2026 — with Graphite App
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13518/streamlit-1.52.2-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13518.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-bnisco sfc-gh-bnisco added impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR labels Jan 6, 2026 — with Graphite App
Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sfc-gh-bnisco sfc-gh-bnisco added the change:breaking PR contains breaking change that affects backwards compatibility label Jan 6, 2026 — with Graphite App
@sfc-gh-bnisco sfc-gh-bnisco requested a review from Copilot January 6, 2026 18:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the isolate_styles parameter in the Custom Components v2 API, moving it from component mount-time to registration-time. This makes the API more intuitive by configuring style isolation once when defining the component, rather than repeatedly at each mount point.

Key changes:

  • Added isolate_styles parameter to the component() function for registration-time configuration
  • Implemented backward compatibility by silently ignoring isolate_styles if passed at mount time
  • Updated documentation examples in type definitions to reflect the new API usage

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lib/streamlit/components/v2/__init__.py Added isolate_styles parameter to component() and _create_component_callable() functions; removed it from _mount_component() signature; added backward compatibility logic to ignore legacy mount-time usage
lib/streamlit/components/v2/types.py Removed isolate_styles documentation from BidiComponentCallable protocol; updated Example 2 to show isolate_styles usage at registration time instead of mount time
lib/tests/streamlit/components/v2/test_component_registry.py Added test test_component_mount_ignores_isolate_styles_kwarg() to verify backward compatibility when isolate_styles is passed at mount time
e2e_playwright/bidi_components/basics.py Removed isolate_styles=True from all component mount calls (4 occurrences) as it's now configured at registration time

@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-06-_feat_move_the_isolate_styles_param_in_ccv2 branch from c52673d to 1d3b6da Compare January 6, 2026 18:52
@sfc-gh-bnisco sfc-gh-bnisco requested a review from Copilot January 6, 2026 18:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-06-_feat_move_the_isolate_styles_param_in_ccv2 branch from 1d3b6da to 399533d Compare January 6, 2026 21:40
@sfc-gh-bnisco sfc-gh-bnisco marked this pull request as ready for review January 6, 2026 22:39
@lukasmasuch
Copy link
Collaborator

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍 but maybe it makes sense to show a deprecation warning via show_deprecation_warning

@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-06-_feat_move_the_isolate_styles_param_in_ccv2 branch from 399533d to d5cd315 Compare January 7, 2026 19:06
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-06-_feat_move_the_isolate_styles_param_in_ccv2 branch from d5cd315 to b9e7980 Compare January 7, 2026 19:14
@sfc-gh-bnisco sfc-gh-bnisco merged commit 1fbbac3 into develop Jan 7, 2026
44 of 45 checks passed
@sfc-gh-bnisco sfc-gh-bnisco deleted the 01-06-_feat_move_the_isolate_styles_param_in_ccv2 branch January 7, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:breaking PR contains breaking change that affects backwards compatibility change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants