I’m trying to let the user enter a list of items to run a computation. This list can be variable in size, but I don’t want it to take the entire screen. This is what I’ve got so far:
import streamlit as st
st.title("A list!")
questions = [st.text_input("Enter your favorite things", "pizza")]
for n in range(5):
questions.append(st.text_input(label='', key=f'Question {n}'))
I have to force a blank label and come up with a set key for each one of the questions. Even five items take up my entire screen! Looking at the html, it looks like it’s inserting an empty <label> element which creates the extra space. Removing this looks like
Looking at it, I think if label is an empty string, not outputting a <label></label> html element would solve this. I can create a PR if there is interest!
The problem with textarea is that each item is specific entry. If I used a textarea, I would have to manipulate the string coming out of it and hope that the user followed some instructions (like one line per entry). This seems more foolproof, but I’ll see if it works for my case.
Either way, a text_input with an empty label should not be putting in extra space. I can think of another use case where you might want a different item above it (like say a picture) and then the label space is sill superfluous.
I’m interested in this too. I have LaTeX, like $x_1$, written above my text_inputs, and then the label is blank. It creates an unaesthetic extra space.
import streamlit as st
st.title("A list!")
questions = [st.text_input("Enter your favorite things", "pizza")]
for n in range(5):
questions.append(
st.text_input(label=f'Question {n}', label_visibility="collapsed")
)
Thank you! that solved my problem. I was not aware of the collapsed option for label_visibility, I was using “hidden” and that left lots of extra space.