-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
feature:st.textRelated to the `st.text` elementRelated to the `st.text` elementtype:enhancementRequests for feature enhancements or new featuresRequests for feature enhancements or new features
Description
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
st.text behavior seems to have changed between 1.37 and the latest version (1.41) in which it no longer respects pre-formatted spacing.
Reproducible Code Example
import streamlit as st
def display_preformatted_text():
preformatted_text = """
Interface: GigabitEthernet1/0/1
MAC Address: 00:1A:2B:3C:4D:5E
IPv4 Address: 192.168.1.10
IPv6 Address: fe80::1a2b:3c4d:5e6f
User-Name: user1
User-Role: admin
Status: active
Domain: example.com
Current Policy: default
Vlan: 10
Device-name: device1
"""
st.text(preformatted_text)
st.write(preformatted_text)
st.code(preformatted_text,language=None )
display_preformatted_text()Steps To Reproduce
Should be demonstrated in example code (self-evident)
Expected Behavior
Adding an option to preserve spacing like previous behavior
Current Behavior
Screenshot of before (1.37) -> (1.41):

While I am aware I can get similar results with st.code it does add a grey background that I can't seem to remove. An option to remove the grey background on st.code to the standard black might be sufficient too.
I think ideally, I would like the option to preserve spacing(old behavior) or not preserve spacing (current behavior).
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.41
- Python version: 3.12
- Operating System: win
- Browser: edge
Additional Information
No response
github-actions, chewqiutrain and mdlacasse
Metadata
Metadata
Assignees
Labels
feature:st.textRelated to the `st.text` elementRelated to the `st.text` elementtype:enhancementRequests for feature enhancements or new featuresRequests for feature enhancements or new features
