Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

utkanuygur
Copy link

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.

Added the the new functionality with documentation.
@jrieke
Copy link
Collaborator

jrieke commented Apr 24, 2024

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.

@utkanuygur
Copy link
Author

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
Copy link
Author

@jrieke Hi! Any updates?

@LukasMasuch
Copy link
Collaborator

@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.

Copy link

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 github-actions bot added the stale label May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants