Skip to content

Custom Dark Theme - support light/dark config inheritance & populate new session msg#12707

Merged
mayagbarnes merged 7 commits intodevelopfrom
custom-dark-theme-2
Oct 10, 2025
Merged

Custom Dark Theme - support light/dark config inheritance & populate new session msg#12707
mayagbarnes merged 7 commits intodevelopfrom
custom-dark-theme-2

Conversation

@mayagbarnes
Copy link
Copy Markdown
Collaborator

@mayagbarnes mayagbarnes commented Oct 7, 2025

Describe your changes

Part 2 of Custom Dark Theme Feature
PR handles setting of theme config values for all sections - [theme], [theme.sidebar], [theme.light], [theme.dark], [theme.light.sidebar],[theme.dark.sidebar] - in new session message / proper section precedence between a base theme .toml file, config.toml, CLI flags & env vars.

This PR finishes handling of theme configs for respective sections, producing the expected nested structure (themeInput example below). This will be used by the FE in the next PR.

    {
        "base": "light",  
        "primaryColor": "blue",  
        "sidebar": {...},        # Config options from theme.sidebar
        "light": {               # Config options from theme.light
            ...other options...
            "sidebar": {...},    # Config options from theme.light.sidebar
        },
        "dark": {                # Config options from theme.dark
            ...other options...
            "sidebar": {...},    # Config options from theme.dark.sidebar
        },
        ...other theme options...
    }

Testing Plan

  • Python Unit Tests: ✅ Added
  • Manual Testing: ✅

@mayagbarnes mayagbarnes added security-assessment-completed change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Oct 7, 2025
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Oct 7, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 7, 2025

✅ PR preview is ready!

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

@mayagbarnes mayagbarnes changed the title [WIP] Custom Dark Theme - support light/dark config inheritance & send to FE Custom Dark Theme - support light/dark config inheritance & send to FE Oct 7, 2025
@mayagbarnes mayagbarnes marked this pull request as ready for review October 7, 2025 19:10
@mayagbarnes mayagbarnes requested a review from Copilot October 7, 2025 19:33
Copy link
Copy Markdown
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 implements part 2 of the Custom Dark Theme feature by adding support for light/dark theme configuration inheritance and sending structured theme data to the frontend. It expands theme configuration to support nested sections like [theme.light], [theme.dark], [theme.light.sidebar], and [theme.dark.sidebar], with proper precedence handling between base theme files, config.toml, CLI flags, and environment variables.

Key Changes

  • Enhanced theme configuration system to support light/dark specific sections and nested sidebar configurations
  • Updated theme validation and inheritance processing to handle complex section structures
  • Modified session message creation to populate all theme sections for frontend consumption

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/tests/streamlit/runtime/app_session_test.py Refactored mock configuration helper and added comprehensive tests for new theme sections
lib/tests/streamlit/config_util_test.py Updated tests to reflect new theme validation structure and added comprehensive inheritance tests
lib/tests/streamlit/config_test.py Enhanced integration tests for complex theme inheritance scenarios
lib/streamlit/runtime/app_session.py Added theme message population for all new theme sections (light, dark, nested sidebars)
lib/streamlit/errors.py Refined theme error classes for better error handling and messaging
lib/streamlit/config_util.py Extensively refactored theme validation and inheritance processing for nested sections

@mayagbarnes mayagbarnes changed the title Custom Dark Theme - support light/dark config inheritance & send to FE Custom Dark Theme - support light/dark config inheritance & populate new session msg Oct 7, 2025

with self._theme_file(theme_content) as theme_file:
# Config file references theme file and sets some overrides
config_toml = f"""
Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch Oct 8, 2025

Choose a reason for hiding this comment

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

With the following config:

[theme]
primaryColor = "#0"

[theme.dark]
primaryColor = "#1"

[theme.sidebar]
primaryColor = "#2"

What would be the expected primaryColor used on the dark theme sidebar? does theme.dark or theme.sidebar take precedence here?

Copy link
Copy Markdown
Collaborator Author

@mayagbarnes mayagbarnes Oct 8, 2025

Choose a reason for hiding this comment

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

This portion of the logic will actually be handled in a subsequent PR (FE), but is an outstanding clarification question I have anyway - @jrieke what are your thoughts?
Should config section precedence (from lower to higher) look like:

  • Option 1: Dark theme sidebar = theme < theme.dark < theme.sidebar < theme.dark.sidebar
  • Option 2: Dark theme sidebar = theme < theme.sidebar < theme.dark < theme.dark.sidebar

Per spec:

[theme.light] and [theme.dark] should inherit any changes from [theme], and [theme.light.sidebar] and [theme.dark.sidebar] should inherit any changes from [theme.sidebar]

Which seems to indicate Option 1 to be correct?

@mayagbarnes mayagbarnes merged commit 25a2533 into develop Oct 10, 2025
38 checks passed
@mayagbarnes mayagbarnes deleted the custom-dark-theme-2 branch October 10, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants