File size: 2,437 Bytes
b0e0325
 
 
 
cb989c0
 
c2ca9a5
b0e0325
c2ca9a5
b0e0325
 
c2ca9a5
b0e0325
 
c2ca9a5
0e279cf
 
 
 
c2ca9a5
cb989c0
c2ca9a5
 
 
 
 
 
 
 
 
 
 
 
 
0e279cf
 
 
 
 
 
c2ca9a5
 
 
 
b0e0325
c2ca9a5
 
cb989c0
 
 
 
 
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
47
48
49
50
51
52
53
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, set font size, and add a border
    styled_text = f'<div style="color:{color}; font-size: 32px; font-weight: bold; border: 2px solid {color}; padding: 10px;">{text}</div>'
    return styled_text

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

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

# Predefined color selection
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.color_picker("Choose a custom color:")
    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)

# Add a separate custom button
if st.button("Customize Text Color"):
    selected_color = st.color_picker("Choose a custom color:")
    styled_text = change_text_color(user_text, selected_color)
    st.markdown(styled_text, unsafe_allow_html=True)