Many ways, for your contrived example, but they may or may not work for your actual case.
The most obvious way would be not calling st.rerun(). It doesn’t do anything useful in your example.
If you really, really need to call st.rerun() (do you?), then I would say, use session_state instead of the value parameter to set the initial value of the toggle. Except it doesn’t work for some reason. Probably related to a longstanding bug.
# This code should fix the issue, but it actually doesn't.
st.session_state.setdefault("config_toggle", False)
if st.button("Rerun"):
st.rerun()
st.toggle("toggle", key="config_toggle")
Another option is calling st.button() after calling st.toggle, but using a container to make the button appear above the toggle. This does work.
st.session_state.setdefault("config_toggle", False)
container = st.container()
st.toggle("toggle", key="config_toggle")
if container.button("Rerun"):
st.rerun()
Or just store the value of the button and call st.rerun() at the end if appropriate.
st.session_state.setdefault("config_toggle", False)
must_rerun = st.button("Rerun")
st.toggle("toggle", key="config_toggle")
if must_rerun:
st.rerun()