Display a slider "IF" its related tick box is ticked - How?

Hi guys,

Quick q - Is it possible to display a slider only if its related tick box is ticked?

I’ve tried a few things including the code in the screenshot below

I can’t seem to make that work, hopefully this is possible! :slight_smile:


hi @Charly_Wargnier, when you say it doesn’t work, you mean the slider isn’t appearing?

Could you share some sample code that I can copy/paste and run to reproduce the issue?

1 Like

Thanks Jonathan.

I’ve worked out the issue – pasting the working code below :slight_smile:

import streamlit as st

st.title("Check Boxes")

check_box_1 = st.checkbox("Partial ratio")

check_box_2 = st.checkbox("Token sort ratio", value=True)


if check_box_1 == True:

    Partial_ratio_slider = st.slider('partial ratio values')

if check_box_2 == True:

    Token_sort_slider = st.slider('token sort ratio values')