File size: 915 Bytes
34492bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr

def create_style_tab(demo):
    with gr.TabItem("Style Customization"):
        theme_dropdown = gr.Dropdown(choices=["Default", "Glass", "Monochrome", "Soft"], label="Choose a Theme")
        custom_css = gr.Textbox(label="Custom CSS", placeholder="Enter custom CSS here...")
        apply_button = gr.Button("Apply Style")

        def apply_style(theme, css):
            if theme == "Default":
                demo.theme = gr.themes.Default()
            elif theme == "Glass":
                demo.theme = gr.themes.Glass()
            elif theme == "Monochrome":
                demo.theme = gr.themes.Monochrome()
            elif theme == "Soft":
                demo.theme = gr.themes.Soft()
            
            if css:
                demo.css = css

        apply_button.click(apply_style, inputs=[theme_dropdown, custom_css], outputs=[])

    return demo