How to Combine Custom Input with st.multiselect in Streamlit?

I am trying to use the st.multiselect widget in Streamlit to allow users to select job titles from a predefined list. However, I also want to provide an option for users to input a custom job title if it’s not available in the list.

# Assuming 'job_titles' is your list of job titles
selected_job_titles = st.multiselect(
    label="Job Titles",
    placeholder="Choose an option",

Is there a way to achieve this functionality directly within st.multiselect or is there a recommended workaround for allowing custom input alongside predefined options?

I appreciate any insights or suggestions you can provide. Thank you!

1 Like

Hi @analytics.admin

You can use st.text_input to accept a new element, which can then be added via append() to the existing list job_titles used by st.multiselect

For example, something like:

new_element = st.text_input(‘Add a new element:’, ‘’)

Hope this helps!

Hi @dataprofessor ,

First of all, I’m a big fan of your work and YouTube videos; they’ve been incredibly helpful to me.

Regarding the solution provided earlier, it seems that the user would initially search within the multiselect options. If they don’t find a match, they can then proceed to add a new element. However, this approach splits the input process into two steps. My goal is to streamline the process into a single step, if possible. I hope I’ve clarified my requirements.

Thank you!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.