Sample text in text_area

Hi,
I have a text area but I would like to give the user an option to load a sample text instead of writing one. Ideally this should be done using a button “load sample”.
I am not sure how to change the value of the text_area once the button is clicked without returning the page. something similar to this image:

here is my code so far
text = st.text_area('Enter text to classify', height=200) load_sample_button = st.button('load sample', key='btn-load-sample') submit_button = st.button('Classify', key='btn-raw-txt')

Hi @Omnia, you could try something like this:

import streamlit as st
from streamlit import session_state as ss

if "txt_sample" not in ss: ss.txt_sample = "This is my sample text which I can add to, if required..."
if "wgt_contents" not in ss: ss.wgt_contents = ""

def btncb(): ss.wgt_contents = ss.txt_sample

ss.wgt_contents = st.text_area("My Text", value=ss.wgt_contents, height=200, placeholder="Enter text...")
sc1, sc2, sc3 = st.columns((2,2,5))
sc1.button('Load Sample', key='btn-load-sample', on_click=btncb)
if sc2.button('Show Raw Text', key='btn-raw-txt'): st.write(f"Raw text: {ss.wgt_contents}")

Cheers