Update app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import streamlit as st# 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;}</style>""", unsafe_allow_html=True)# 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")12345678910111213141516171819202122232425262728293031323334353637383940import streamlit as st# Example HTMLhtml_content = """<div class='my-div'><h1>Hello, Streamlit!</h1><p>This is a paragraph in a custom style.</p><button onclick="alert('Button Clicked!');">Click Me</button></div>"""# Example CSScss_content = """<style>.my-div {background-color: lightblue;padding: 10px;border-radius: 10px;text-align: center;}.my-div h1 {color: navy;}.my-div p {font-style: italic;}</style>"""# Combining HTML and CSScombined_content = css_content + html_content# Using Streamlit to render the HTML/CSSst.markdown(combined_content, unsafe_allow_html=True)# Streamlit equivalent componentsst.header("Hello, Streamlit!")st.write("This is a paragraph in a custom style.")if st.button("Click Me"):st.write("Button Clicked!")
app.py+31-42