# Widget inside st.button

**URL:** <https://discuss.streamlit.io/t/widget-inside-st-button/33778>\
**Category:** Using Streamlit\
**Created:** [November 24, 2022, 9:17pm UTC](https://discuss.streamlit.io/t/widget-inside-st-button/33778 "2022-11-24T21:17:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mathcatsand](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mathcatsand/32/48006_2.png) [@mathcatsand](https://discuss.streamlit.io/u/mathcatsand)\
**Post date:** [November 25, 2022, 4:09am UTC](https://discuss.streamlit.io/t/widget-inside-st-button/33778/2 "2022-11-25T04:09:23Z")

</div>

Buttons will only be True immediately after clicked, then go back to False. So if you want a button to conditionally display something, and keep it displaying while you proceed with other interaction, yes, you’d need to use session state.

```auto
if 'show' not in st.session_state:
    st.session_state.show = False

def toggle_show():
    st.session_state.show = not st.session_state.show

st.button('Show', on_click=toggle_show)

if st.session_state.show:
    # Your code, including widgets if you want

```

Instead of setting your condition directly on the button, you use the button to affect something in session state, then condition on that data stored in session state so it persists.

I did a little introductory video on session state geared around widget interaction: [Session State Introduction](https://discuss.streamlit.io/t/session-state-introduction/33462)

---

_[View the full topic](https://discuss.streamlit.io/t/widget-inside-st-button/33778)._
