Basic usage
Constructor
Component(s) to clear when button is clicked
Button label text
Button style variant
Button size
Clear component values with a button click
import gradio as gr
with gr.Blocks() as demo:
text = gr.Textbox(label="Input")
output = gr.Textbox(label="Output")
clear = gr.ClearButton([text, output])
demo.launch()
clear_btn = gr.ClearButton()
clear_btn.add([component1, component2])
import gradio as gr
def process(text, num):
return f"{text} - {num}"
with gr.Blocks() as demo:
with gr.Row():
text_input = gr.Textbox(label="Text")
num_input = gr.Number(label="Number")
output = gr.Textbox(label="Result")
with gr.Row():
submit = gr.Button("Submit")
clear = gr.ClearButton([text_input, num_input, output])
submit.click(fn=process, inputs=[text_input, num_input], outputs=output)
demo.launch()