Update app.py
Browse files2 unmodified lines3456789101112131415161718192021222324252627282930313233343 unmodified lines383940414243444546472 unmodified lines# Use markdown to inject custom styles via HTMLst.markdown("""<style>/* CSS selectors for Streamlit buttons based on their order */div.stButton > button:first-of-type {background-color: red !important;}div.stButton > button:nth-of-type(2) {background-color: blue !important;}/* For text inputs, the placeholder styling is a bit tricky due to browser differences *//* Here, we are overriding the color for all input components */input::placeholder {color: red;opacity: 1; /* For Firefox */}input.stTextInput[type="text"]:first-of-type {background-color: yellow !important;}input.stTextInput[type="text"]:nth-of-type(2) {background-color: green !important;}/* Apply color to the text inputs directly */.stTextInput input {color: black !important;}3 unmodified lines# Title of the appst.title('Customized Streamlit App')# Define text inputstext_input1 = st.text_input("Enter text 1:", '', placeholder='Hello')text_input2 = st.text_input("Enter text 2:", '', placeholder='Goodbye')# Define buttonsbutton1 = st.button("Button 1")button2 = st.button("Button 2")2 unmodified lines345678910111213141516171819202122232425262728293031323334353637383 unmodified lines424344454647484950512 unmodified lines# Use markdown to inject custom styles via HTMLst.markdown("""<style>/* Specifically target the elements based on the data-testid attribute *//* Target the button based on its unique key */[data-testid="stButton"][data-buttontext="Button 1"] > button {background-color: red !important;color: white !important;}[data-testid="stButton"][data-buttontext="Button 2"] > button {background-color: blue !important;color: white !important;}/* Target the text input based on its unique key */[data-testid="stTextInput"][data-testid="text-input1"] > div > div > input {background-color: yellow !important;color: black !important;}[data-testid="stTextInput"][data-testid="text-input2"] > div > div > input {background-color: green !important;color: black !important;}/* Style the placeholders */[data-testid="stTextInput"][data-testid="text-input1"] > div > div > input::placeholder {color: black !important;}[data-testid="stTextInput"][data-testid="text-input2"] > div > div > input::placeholder {color: black !important;}3 unmodified lines# Title of the appst.title('Customized Streamlit App')# Define text inputs with unique key identifierstext_input1 = st.text_input("Enter text 1:", '', placeholder='Hello', key="text-input1")text_input2 = st.text_input("Enter text 2:", '', placeholder='Goodbye', key="text-input2")# Define buttons with unique key identifiersbutton1 = st.button("Button 1", key="button1")button2 = st.button("Button 2", key="button2")
app.py+24-20