import gradio as gr # Color options with their hex codes COLORS = { "red": "#FF0000", "yellow": "#FFD700", "green": "#00FF00", "blue": "#0000FF", "indigo": "#4B0082", "purple": "#800080", "pink": "#FFC0CB", "gray": "#808080" } def create_gradient(color_from, color_to): # Create HTML with gradient background html = f"""
""" return html # Create the Gradio interface with gr.Blocks() as demo: gr.Markdown("# Gradient Color Preview") gr.Markdown("Select colors to preview how they would look in your space's thumbnail.") with gr.Row(): color_from = gr.Dropdown( choices=list(COLORS.keys()), value="blue", label="Color From" ) color_to = gr.Dropdown( choices=list(COLORS.keys()), value="purple", label="Color To" ) preview = gr.HTML(label="Preview") # Update preview when colors change color_from.change( fn=create_gradient, inputs=[color_from, color_to], outputs=preview ) color_to.change( fn=create_gradient, inputs=[color_from, color_to], outputs=preview ) # Initial preview preview.value = create_gradient("blue", "purple") if __name__ == "__main__": demo.launch()