Hi everyon,
i have seen a post Displaying newlines in streamlit table
I want to add a new border with each join “\n” like image below
can you help me for this case
Hi everyon,
i have seen a post Displaying newlines in streamlit table
I want to add a new border with each join “\n” like image below
can you help me for this case
You’ll need to add an HTML <hr>
tag and some custom CSS styling to achieve a similar result.
import streamlit as st
import pandas as pd
data = {
"Name": ["John Doe", "Jane Smith", "Bob Johnson"],
"Description": [
"line 1 /n line 2",
"line 3 /n line 4",
"line 5 /n line 6",
],
}
df = pd.DataFrame(data)
# Replace the \n with an HTML linebreak and a horizontal line
df = df.applymap(lambda x: x.replace('/n', '<br><hr>'))
# Inject custom CSS for styling the horizontal rule
st.markdown(
"""
<style>
hr {
height: 1px;
border-width: 0;
color: gray;
background-color: gray;
width: calc(100% + 26px); /* Adjust width to account for padding */
margin: 0;
margin-left: -13px; /* Adjust margin to account for padding */
margin-right: -13px; /* Adjust margin to account for padding */
}
</style>
""",
unsafe_allow_html=True,
)
# Show as a static table
st.markdown(df.to_html(escape=False), unsafe_allow_html=True)
Thank for your support!!
It’s helpfulf with me
Make sure to mark this question as resolved! Cheers
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.