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

Skip to content

Code blocks in label make st.expander criminally ugly #12149

@viktor-shcherb

Description

@viktor-shcherb

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

Here is a real-world example from my chat-history annotation tool:

Image

And here is from the reproduced example:

Image

Reproducible Code Example

import streamlit as st
code_str = """

print('I am hopelessly, breathlessly, madly in love with Streamlit—the smooth-talking, curve-hugging seductress of the coding world that takes raw, unfiltered Python and slips it into something sleek, interactive, and irresistibly gorgeous, making every app feel like a love letter to data, every click a flirtation, and every build a slow, satisfying dance of creation that leaves you wanting more.')

"""
with st.expander("Check out my code!\n" + code_str):
    st.text("Verdict: quite ugly")

st.markdown("Here is what I expected: \n" + code_str)

Steps To Reproduce

No response

Expected Behavior

Horizontally-scrollable code block

Current Behavior

Code block extends over the expander boundary

Is this a regression?

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

Debug info

  • Streamlit version: Streamlit, version 1.48.0
  • Python version: Python 3.11.11
  • Operating System: MacOS
  • Browser: Chrome

Additional Information

On the side note, thank you for the recent visual update of the expanders! Same font size in the preview looks so much better with markdown in the expanded body, before I had to inject CSS to make the collapsed text match the font of the expanded version...

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.expanderRelated to the `st.expander` containerpriority:P3Medium prioritytype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions