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

Widgets do not line up #10153

Open
3 of 4 tasks
alex-bork opened this issue Jan 10, 2025 · 6 comments
Open
3 of 4 tasks

Widgets do not line up #10153

alex-bork opened this issue Jan 10, 2025 · 6 comments
Labels
area:layout status:awaiting-user-response Issue requires clarification from submitter type:bug Something isn't working

Comments

@alex-bork
Copy link

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

Hi,
I try to line up Widgets in 3 seperate columns. Unfortunately that does not work:
streamlit line up widgets

I have found a solution for the text. I could add "######" to the same column and the text would line up with the text_input, but the button has still the problem:
streamlit line up buttons

Best Regards

Reproducible Code Example

for header in headers:
    value = st.session_state.request_headers[header]
    col1, col2, col3 = st.columns([0.3, 0.6, 0.1], vertical_alignment="center")
    with col1:
        "######"
        st.markdown(f"{header}")
    with col2:
        st.text_input("", value=value, key=f"headers{header}")
    with col3:
        # st.markdown("######") -> this does not help for the button
        st.button("", key=f"header_del_{header}", on_click=delete_header, args=[header], icon=":material/clear:")

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

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

Debug info

  • Streamlit version:
  • Python version:
  • Operating System:
  • Browser:

Additional Information

No response

@alex-bork alex-bork added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Jan 10, 2025
Copy link

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@alex-bork
Copy link
Author

alex-bork commented Jan 10, 2025

and with solution where I use "#####" in order to shift the text down I now have big spaces between the rows:
streamlit line up spaces

@alex-bork
Copy link
Author

using text or markdown instead of text_input looks good:
streamlit line up text

@jrieke
Copy link
Collaborator

jrieke commented Jan 10, 2025

Hey! This is because the text input still shows an (empty) label above it. You can get rid of that with label_visibility="collapsed". This also allows you to actually set a label on the text input (which is great for accessibility!) but not show it in the UI. So you could do something like this:

st.text_input(f"{header} value", value=value, key=f"headers{header}", label_visibility="collapsed")

Let me know if that works so we can close this issue. We also want to work more on layout solutions in the next few months, so I added this issue to our internal notes on that!

@jrieke jrieke added status:awaiting-user-response Issue requires clarification from submitter and removed status:needs-triage Has not been triaged by the Streamlit team labels Jan 10, 2025
@lukasmasuch
Copy link
Collaborator

Also, vertical_alignment="bottom" might work better in this case.

@jrieke
Copy link
Collaborator

jrieke commented Jan 10, 2025

Also, vertical_alignment="bottom" might work better in this case.

Yeah I thought so too in the beginning, but the label on the left side doesn't look good anymore in that case because it's misaligned with the widget placeholder text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:layout status:awaiting-user-response Issue requires clarification from submitter type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants