I produced a few tables in Streamlit and would like to show the download buttons for this table in various formats underneath it. This is working as intended, the only problem I have is that the buttons are shown below each other.
I am aware that this was a topic before (for instance here), the problem of this approach (with separate columns) is that the gap depends on the size of the screen/window.
Is there by now a possibility to show the buttons directly next to each other without having to rely on columns (or with columns, if it serves the purpose)? I am also open to other solutions of course
thank you for your reply. If I understand correctly, then the gap would be different depending if I look at the streamlit app on a mobile device or a wide screen. How can I ensure that the buttons (in my case three or four depending on the table) are aligned to the left with a small gap in-between (regardless of the window size)?
If you’re like me, it might bother you that the columns equally space, making layout not visually appealing because the buttons appear far apart.
After a lot of CSS digging, I found a pretty simple approach that doesn’t require any other library installs. After creating the columns as show above, it is possible (at least for the current version of streamlit) to apply the following CSS to make columns only as wide as the button. I included this at the top of my file:
Sorry to disappoint - I think it’s all or nothing. When the columns are generated by Streamlit, there does not seem to be a way to control the CSS that is applied to them. The only way this would be possible is if st.columns allowed the user to pass a class name or some other HTML property, but I doubt that’s possible.
As a side note - if it is possible to put your other content on another page of a multi-page application. You could apply this column hack to one page but not the other.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
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.
Performance cookies
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.
Functional cookies
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.
Targeting cookies
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.