I’m developing a Streamlit app and need help fixing the st.file_uploader() at the bottom of the page, alongside a chat input (st.chat_input()). While the chat input stays fixed at the bottom, the image upload option scrolls with the page.
How can I make the st.file_uploader() stay fixed at the bottom, just like the chat input? Any suggestions?
A hackish approach that works for all Streamlit elements is to use st.html.
You can manipulate <style> of this element to ensure that it’s anchored to the bottom of the page always.
Another plausible approach here can be - To inject this element inside the footer container. This also includes manipulating elements by injecting js script inside st.html.
I have been using this approach for manipulate placement of streamlit elements for about 2 years now and happy to share that this approach works very stably.
st.chat_input is a bit especial because it is placed by default in st._bottom. You can access that container the same way you’d add elements to st.sidebar, for example:
import streamlit as st
st.title(":cat:")
st.write("Some repeated text. " * 50)
with st._bottom:
left_col, right_col = st.columns(2)
with left_col:
st.subheader("Hello chat:")
chat = st.chat_input("Type here your question...")
with right_col:
uploaded_file = st.file_uploader("Upload a file")
The only downside is that the main content in the page will automatically scroll all the way down, which would be useful to display a chat history, but not much else. st._bottom is not officially supported so it’s not in the docs but it can be found in the source code.
Also, related, file inputs in st.chat_input is in development:
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.