Update dynamic values based on slider output to a table

Ah, I see. I think I understand what you mean.

Here is a minimal example:

import streamlit as st

text_length = st.slider("Choose text length", min_value=1, max_value=10, step=1)
full_text = 'abcdefghij'
output_text = full_text[:text_length]

st.markdown(output_text) 

And then you can style your text using markdown (see https://docs.streamlit.io/en/latest/api.html#display-text) or even HTML+CSS (kind of hacky, see Colored boxes around sections of a sentence for inspiration). In this way, you can also for example add a rectangular box around the text.

Hope it helps!

1 Like