Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Function to change text color based on user input
|
| 4 |
+
def change_text_color(text, color):
|
| 5 |
+
# Apply HTML styling to change text color
|
| 6 |
+
styled_text = f'<span style="color:{color};">{text}</span>'
|
| 7 |
+
return styled_text
|
| 8 |
+
|
| 9 |
+
# Streamlit app
|
| 10 |
+
st.title("Text Color Changer")
|
| 11 |
+
|
| 12 |
+
# Input text and color selection
|
| 13 |
+
user_text = st.text_input("Enter your text:")
|
| 14 |
+
selected_color = st.selectbox("Select text color:", ["red", "blue", "green", "orange"])
|
| 15 |
+
|
| 16 |
+
# Apply text color change and display
|
| 17 |
+
styled_text = change_text_color(user_text, selected_color)
|
| 18 |
+
st.markdown(styled_text, unsafe_allow_html=True)
|