Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import streamlit as st# Add custom CSS with class names using st.markdownst.markdown("""<style>/* Style for custom button class */.custom-button {color: white;background-color: #008CBA;padding: 10px 24px;border: none;border-radius: 10px;cursor: pointer;font-size: 20px;}/* Style for custom text input class */.custom-text-input {height: 40px;padding: 8px;color: #333333;background-color: #f4f4f4;border: 2px solid #cccccc;border-radius: 5px;}</style>""", unsafe_allow_html=True)# Title of the appst.title('Custom Style Example')# Input text boxes with custom classtext_input1 = st.text_input("Enter text 1:", value='', max_chars=None, key=None, type='default', help=None, placeholder=None, class="custom-text-input")text_input2 = st.text_input("Enter text 2:", value='', max_chars=None, key=None, type='default', help=None, placeholder=None, class="custom-text-input")text_input3 = st.text_input("Enter text 3:", value='', max_chars=None, key=None, type='default', help=None, placeholder=None, class="custom-text-input")# Buttons with custom classbutton1 = st.button("Button 1", class="custom-button")button2 = st.button("Button 2", class="custom-button")# You can also use the returned value of class-assigned elements# For example:# button1_pressed = st.button("Button 1", class="custom-button")# if button1_pressed:# st.write("Button 1 was clicked!")# Styling using class names should be reflected in the appearance of the text inputs and buttons when you run the Streamlit app.123456789101112131415161718192021222324252627282930313233343536373839404142434445import streamlit as st# Insert custom CSS via st.markdownst.markdown("""<style>/* Style overrides for Streamlit buttons */.css-2trqyj {background-color: #008CBA;color: white;border-radius: 10px;border: none;height: 3em;font-size: 1em;padding: .25em 1em;}/* Hover effects for Streamlit buttons */div.stButton > button:hover {background-color: #005f73;}/* Style overrides for Streamlit text input */.stTextInput > div > div > input {background-color: #f1f1f1;}</style>""", unsafe_allow_html=True)# Title of the appst.title('Styled Streamlit Widgets')# Input text boxestext_input1 = st.text_input("Enter text 1:")text_input2 = st.text_input("Enter text 2:")text_input3 = st.text_input("Enter text 3:")# Buttonsbutton1 = st.button("Button 1")button2 = st.button("Button 2")# Output the input statusif button1:st.write("Text input 1:", text_input1)if button2:st.write("Text input 2:", text_input2)
app.py+30-32