File size: 2,080 Bytes
b0e0325
 
 
 
0e279cf
 
 
 
b0e0325
0e279cf
b0e0325
 
 
 
 
0e279cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b0e0325
0e279cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import streamlit as st

# Function to change text color based on user input
def change_text_color(text, color):
  # Apply HTML styling to change text color
  styled_text = f'<span style="color:{color};">{text}</span>'
  
  return styled_text

# Streamlit app  
st.title("Text Color Changer")

# Input text and color selection
user_text = st.text_input("Enter your text:")

st.subheader("Select text color:")

# Expanded list of predefined color options
color_options = [
  "red", "blue", "green", "orange", "yellow", "purple", "pink", "brown", "gray", 
  "cyan", "magenta", "violet", "indigo", "lime", "olive", "teal", "navy", "maroon",
  "aquamarine", "azure", "beige", "black", "fuchsia", "silver", "white", 
  "lavender", "turquoise", "plum", "salmon", "sienna", "tomato", "wheat", "orchid", 
  "thistle", "peru", "royalblue", "dodgerblue", "darkslategray", "darkseagreen", 
  "darkred", "darkorange", "darkolivegreen", "darkmagenta", "darkkhaki", "darkgray",
  "darkcyan", "darkblue", "darkgoldenrod", "mediumblue", "mediumorchid", 
  "cornflowerblue", "chocolate", "coral", "crimson", "forestgreen", "gainsboro",
  "goldenrod", "hotpink", "ivory", "khaki", "lawngreen", "lightcyan", "lightgrey",
  "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
  "mediumaquamarine", "mediumslateblue", "mediumspringgreen", "midnightblue", 
  "mistyrose", "moccasin", "navajowhite", "oldlace", "olivedrab", "orangered",
  "palevioletred", "peachpuff", "rebeccapurple", "rosybrown", "seagreen", 
  "seashell", "slateblue", "slategray", "springgreen", "steelblue", "tan",
  "transparent", "wheat"  
]

# User can select a predefined color or input a custom color code
selected_color = st.selectbox("Select a color:", color_options + ["Custom"])

if selected_color == "Custom":
  custom_color_code = st.text_input("Enter a custom color code (e.g., #RRGGBB or a color name):")
  selected_color = custom_color_code
  
# Apply text color change and display  
styled_text = change_text_color(user_text, selected_color)
st.markdown(styled_text, unsafe_allow_html=True)