Hi,
I came up with the following solution that improves on method 3 as it does not lose all selected options when removing single ones after clicking “Select all”. It uses the st.session_state
and a callback for the “Select all” button and looks a bit hacky :
import streamlit as st
st.header("Option 4")
all_options = ["A", "B", "C"]
selected_options_4 = st.multiselect(
"Select one or more options:", all_options, key="selected_options_4"
)
def _select_all():
st.session_state.selected_options_4 = all_options
st.button("Select all", on_click=_select_all)
selected_options_4