Skip to content

Use theme primary color for st.map default markers#14539

Open
Jesseman-418 wants to merge 1 commit intostreamlit:developfrom
Jesseman-418:fix/map-theme-colors
Open

Use theme primary color for st.map default markers#14539
Jesseman-418 wants to merge 1 commit intostreamlit:developfrom
Jesseman-418:fix/map-theme-colors

Conversation

@Jesseman-418
Copy link
Copy Markdown

Summary

Closes #12805

  • Replaces the hardcoded red marker color (200, 30, 0, 160) in st.map with the theme's primary color (with semi-transparency)
  • When a custom theme with primaryColor is configured via .streamlit/config.toml, st.map now uses that color for default markers
  • Falls back to Streamlit's built-in default primary color (#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 color

Changes

lib/streamlit/elements/map.py:

  • Replaced _DEFAULT_COLOR = (200, 30, 0, 160) with _get_default_color() function that reads config.get_option("theme.primaryColor")
  • Added _DEFAULT_ALPHA = 160 constant for the semi-transparency value
  • Added _FALLBACK_COLOR = (255, 75, 75, 160) matching Streamlit's default primary (red70)
  • Updated docstring for the color parameter to mention theme-based default

Scope

This PR addresses the st.map portion of #12805. The st.pydeck_chart side is not changed here because users construct pydeck.Deck objects themselves with explicit color values — changing those defaults would require changes in the PyDeck library or a more involved frontend interception approach.

Test plan

  • Verify st.map(df) renders markers in the default Streamlit primary color (#ff4b4b) when no custom theme is set
  • Verify st.map(df) renders markers in the custom theme primary color when primaryColor is set in .streamlit/config.toml
  • Verify st.map(df, color="#00ff00") still uses the explicitly provided color (no regression)
  • Verify st.map(df, color="col_name") still works with column-based colors
  • Verify existing map tests pass

🤖 Generated with Claude Code

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Mar 27, 2026

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

Status Scan Engine 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.

@github-actions
Copy link
Copy Markdown
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:

  1. Initial triage: A maintainer will apply labels, approve CI to run, and trigger AI-assisted reviews. Your PR may be flagged with status:needs-product-approval if the feature requires product team sign-off.

  2. Code review: A core maintainer will start reviewing your PR once:

    • It is marked as 'ready for review', not 'draft'
    • It has status:product-approved (or doesn't need it)
    • All CI checks pass
    • All AI review comments are addressed

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]>
@Jesseman-418 Jesseman-418 force-pushed the fix/map-theme-colors branch from e2c5ff9 to baa2c3f Compare March 27, 2026 05:41
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.

Use theme colors in st.map and st.pydeck_chart

1 participant