streamlit icon indicating copy to clipboard operation
streamlit copied to clipboard

Added border as a parameter to st.columns with appropriate documentation

Open utkanuygur opened this issue 1 year ago • 4 comments

Changes

Added a new border parameter to the st.columns function, similar to the functionality in the st.container function. This allows users to specify whether they want a border around the columns or not.

  • Added a new border parameter to the st.columns function signature, with a default value of None.
  • Inside the column_proto function, set col_proto.vertical.border to border or False. This ensures that if border is None, no border will be shown, and if border is True, a border will be shown around the columns.
  • Updated the function docstring to include information about the new border parameter and provide example usage.

GitHub Issue Link #8547

Manual Testing

import streamlit as st

container = st.container(border=True)
container.write("This is inside the container")
st.write("This is outside the container")

container.write("This is inside too")
col1, col2 = st.columns(2, border=True)
col3, col4 = st.columns(2, border=False)

with col1:
    st.markdown("Content in column 1")

with col2:
    st.markdown("Content in column 2")

with col3:
    st.markdown("Col 3 has no border")

with col4:
    st.markdown("So does col 4")

ss

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

utkanuygur avatar Apr 23 '24 03:04 utkanuygur

This is great, thanks! Can you post a screenshot of how it looks like when the columns have content of different heights? Just want to see how the borders at the bottom align since that's something we probably have to think about. I'm on a conference today but will have a closer look in the next few days and also ping one of pur engs to review the code.

jrieke avatar Apr 24 '24 12:04 jrieke

This is great, thanks! Can you post a screenshot of how it looks like when the columns have content of different heights? Just want to see how the borders at the bottom align since that's something we probably have to think about. I'm on a conference today but will have a closer look in the next few days and also ping one of pur engs to review the code.

Thanks for reviewing my PR! I've just tested it, and the columns are aligned regardless.

import streamlit as st

container = st.container(border=True)
container.write("This is inside the container")
st.write("This is outside the container")

container.write("This is inside too")
col1, col2 = st.columns(2, border=True)
col3, col4 = st.columns(2, border=False)

with col1:
    st.markdown("""Content in column 1    
The content has multiple rows""")

with col2:
    st.markdown("Col 2 is aligned!")

with col3:
    st.markdown("Col 3 has no border")

with col4:
    st.markdown("So does col 4")

Screenshot 2024-04-24 161526

utkanuygur avatar Apr 24 '24 20:04 utkanuygur

@jrieke Hi! Any updates?

utkanuygur avatar Apr 29 '24 23:04 utkanuygur

@utkanuygur Thanks for the contribution. Unfortunately, the way how this is implemented breaks other aspects of column. Thats also why the tests are failing. We would need to add a dedicated border property to the column proto instead of doing: col_proto.vertical.border = border or False, which would be a bit more work.

lukasmasuch avatar May 03 '24 17:05 lukasmasuch

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 18 '24 01:05 github-actions[bot]