skillfed

st-theme

A component that returns the active theme of the Streamlit app.

st-theme v1.2.3 314.2K downloads/30d#7,703 on PyPI16
Permissive license MIT License DORMANT released

What it is and what it does

st-theme is a Streamlit component that queries the active theme of a running Streamlit app and returns it as a dictionary of style settings. It integrates directly into a Streamlit app's frontend to detect whether the user has selected light or dark mode, and updates the returned value whenever the user manually changes the theme after the app is running.

The package is designed to be lightweight and non-intrusive: by default it applies a CSS adjustment to remove the empty space that Streamlit normally reserves for rendered components, since st-theme only communicates with the frontend and renders nothing visible. This behavior can be disabled via the adjust parameter if it conflicts with your app's layout. The main gotcha is a known browser-dependent timing issue where the theme may not be returned immediately on first load, though it updates normally when the user switches themes afterward.

Use it for:

  • Dynamically style a Streamlit app's custom content based on whether the user has selected light or dark mode
  • Detect the initial theme setting to apply a fallback configuration when st-theme returns None on first load
  • Build theme-aware custom components that respond to the active Streamlit theme without requiring manual user input
  • Log or track theme preferences in a Streamlit analytics or monitoring system

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Detects and returns the active theme (light or dark) of a running Streamlit app, updating dynamically when the user changes the theme.

Yes, with conditions. Install if you need to detect and respond to Streamlit's active theme in your app and can work around the known initial-load timing issue by providing a fallback. The low install friction, permissive license, and stable classifier make it straightforward to add. However, the 833-day maintenance gap means no recent bug fixes or Streamlit version updates—verify compatibility with your Streamlit version before relying on it in production.

Install

st-theme on PyPI

pip

pip install st-theme

uv

uv add st-theme

poetry

poetry add st-theme

Installing st-theme

Before you install

Low friction: pure Python wheel with only streamlit as a runtime dependency. Maintenance is dormant—last release was 833 days ago and the repository shows no recent activity, though it remains unarchived and marked Production/Stable.

License in practice

MIT License (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install st-theme

import streamlit as st
from st_theme import st_theme

theme = st_theme()
st.write(theme)

Requires Streamlit 1.20+. The CSS adjustment feature depends on browser support for the :has pseudo-class; initial theme detection may return None on first load due to a known browser-dependent timing issue.

Verify before relying

  • Whether the known timing bug (theme returning None on initial load) has been resolved in version 1.2.3
  • Current compatibility with Streamlit versions beyond 1.20 given 833 days since last release
  • Whether the :has pseudo-class browser compatibility limitation affects a significant portion of target users

Package facts

License MIT License (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — streamlit
Maintenance dormant — 833 days since the last release
Last repo commit
First released
Downloads 314,184/month — #7,703 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: st_theme-1.2.3-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: ConsoleEnvironment :: Web EnvironmentIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Database :: Front-EndsTopic :: Office/Business :: Financial :: SpreadsheetTopic :: Scientific/Engineering :: Information AnalysisTopic :: Scientific/Engineering :: VisualizationTopic :: Software Development :: Libraries :: Application FrameworksTopic :: Software Development :: Widget Sets

Tags

streamlit theme detectionget streamlit app themestreamlit light dark modestreamlit theme componentdetect streamlit themestreamlit theme settings
streamlit-componenttheme-detection

More Application Frameworks packages