Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Custom Components Not Inheriting Theme CSS Variables (e.g. --font) After Streamlit Version 1.43 #10660

@Panosero

Description

@Panosero

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Since Streamlit version 1.43, our custom components running in iframes no longer inherit the theme CSS variables—specifically the --font variable used for font styling. For instance, the StreamlitAntdComponents library sets its font via CSS using fontFamily: 'var(--font)'. In earlier versions (e.g. before 1.43), the parent app’s theme correctly propagated the --font value into the custom component iframes. However, with Streamlit 1.43 and later, these variables aren’t automatically available in iframes, causing components to fall back to browser default fonts.

Reproducible Code Example

import streamlit as st
import streamlit_antd_components as sac

# Set page configuration (optional)
st.set_page_config(page_title="My Streamlit App", layout="wide")


def show_me_repo_versions():
    # show me streamlit and streamlit_antd_components versions
    st.write("Streamlit version:", st.__version__)
    st.write("Streamlit Antd Components version:", sac.__VERSION__)


def main():
    """Main function for the Streamlit application."""

    st.title("My Streamlit App with Ant Design Components")
    st.write("This is a simple example of using Ant Design components in Streamlit.")
    if st.button("Click Me"):
        st.success("Button clicked!")
    st.selectbox("Select an option", ["Option 1", "Option 2", "Option 3"])
    st.select_slider("Select a range", options=["Option 1", "Option 2", "Option 3"])
    # st.dataframe example:
    st.dataframe(
        {
            "Column 1": [1, 2, 3],
            "Column 2": ["A", "B", "C"],
        }
    )
    with st.container():
        show_me_repo_versions()
    with st.sidebar:
        st.header("Sidebar")
        st.write("This is the sidebar content.")
        sac.menu(
            [
                sac.MenuItem(
                    "home", icon="house-fill", tag=[sac.Tag("Tag1", color="green"), sac.Tag("Tag2", "red")]
                ),
                sac.MenuItem(
                    "products",
                    icon="box-fill",
                    children=[
                        sac.MenuItem("apple", icon="apple"),
                        sac.MenuItem(
                            "other",
                            icon="git",
                            description="other items",
                            children=[
                                sac.MenuItem("google", icon="google", description="item description"),
                                sac.MenuItem("gitlab", icon="gitlab"),
                                sac.MenuItem("wechat", icon="wechat"),
                            ],
                        ),
                    ],
                ),
                sac.MenuItem("disabled", disabled=True),
                sac.MenuItem(type="divider"),
                sac.MenuItem(
                    "link",
                    type="group",
                    children=[
                        sac.MenuItem(
                            "antd-menu", icon="heart-fill", href="https://ant.design/components/menu#menu"
                        ),
                        sac.MenuItem(
                            "bootstrap-icon", icon="bootstrap-fill", href="https://icons.getbootstrap.com/"
                        ),
                    ],
                ),
            ],
            open_all=True,
        )


if __name__ == "__main__":
    main()

Steps To Reproduce

  1. run the above in the latest and the 1.42 versions

Expected Behavior

inherit streamlit fonts

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.43
  • Python version: 3.13
  • Operating System:Mac OS
  • Browser: Chrome

Additional Information

existing behaviour:

Image

older vesions:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P1High priority - fix within two weeksstatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedtype:regressionThis bug is a regression from previous behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions