St.radio() split into parts, accepting dictionary as input

Hey @kierancondon!

While the Streamlit team is figuring out if your proposal would fit their plans, I think that’s a good idea for a custom component so I put it in the tracker for grabs :slight_smile: (though it wouldn’t work in the sidebar).

With our current building blocks, though it goes against your wish I would separate each section in a selectbox. I understand you wouldn’t be able to see all of the pages at once + whenever you change section, one of the pages would be autoamtically selected and displayed unless you use an empty first placeholder item, but it enforces only one page is selected at a time.

import streamlit as st

dictionary = {'Classification': ['Linear', 'Tree'], 'Regression': ['Logistic', 'Random']}

st.title("Choose your ML model")

selected_section = st.sidebar.selectbox("Choose section:", sorted(dictionary.keys()))
selected_page = st.sidebar.radio("Choose page:", sorted(dictionary[selected_section]))

if st.button("Run model"):
    st.write(f"Running {selected_section}:{selected_page}")

test

Cheers,
Fanilo

1 Like