Use theme primary color for st.map default markers#14539
Open
Jesseman-418 wants to merge 1 commit intostreamlit:developfrom
Open
Use theme primary color for st.map default markers#14539Jesseman-418 wants to merge 1 commit intostreamlit:developfrom
Jesseman-418 wants to merge 1 commit intostreamlit:developfrom
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
|
Thanks for contributing to Streamlit! 🎈 Please make sure you have read our Contributing Guide. You can find additional information about Streamlit development in the wiki. The review process:
We're receiving many contributions and have limited review bandwidth — please expect some delay. We appreciate your patience! 🙏 |
Replace the hardcoded default marker color (200, 30, 0, 160) in st.map with the user's active theme primary color. This is done by passing a sentinel string "@@st.theme.primaryColor" from the Python backend, which the frontend resolves to the actual theme RGBA value before handing the deck.gl spec to the renderer. The same mechanism is available for st.pydeck_chart users who want to reference theme colors in their layer configs. Fixes streamlit#12805 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
e2c5ff9 to
baa2c3f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #12805
(200, 30, 0, 160)inst.mapwith the theme's primary color (with semi-transparency)primaryColoris configured via.streamlit/config.toml,st.mapnow uses that color for default markers#ff4b4b/red70) when no custom theme is set — this also updates the previous default from a dark red(200, 30, 0)to match Streamlit's actual primary colorChanges
lib/streamlit/elements/map.py:_DEFAULT_COLOR = (200, 30, 0, 160)with_get_default_color()function that readsconfig.get_option("theme.primaryColor")_DEFAULT_ALPHA = 160constant for the semi-transparency value_FALLBACK_COLOR = (255, 75, 75, 160)matching Streamlit's default primary (red70)colorparameter to mention theme-based defaultScope
This PR addresses the
st.mapportion of #12805. Thest.pydeck_chartside is not changed here because users constructpydeck.Deckobjects themselves with explicit color values — changing those defaults would require changes in the PyDeck library or a more involved frontend interception approach.Test plan
st.map(df)renders markers in the default Streamlit primary color (#ff4b4b) when no custom theme is setst.map(df)renders markers in the custom theme primary color whenprimaryColoris set in.streamlit/config.tomlst.map(df, color="#00ff00")still uses the explicitly provided color (no regression)st.map(df, color="col_name")still works with column-based colors🤖 Generated with Claude Code