Introducing Gradio Clients

Watch

New to Gradio? Start here: Getting Started

See the Release History

ClearButton

gradio.ClearButton(···)
import gradio as gr with gr.Blocks() as demo: textbox = gr.Textbox(value="This is some text") gr.ClearButton(textbox) demo.launch()

Description

Button that clears the value of a component or a list of components when clicked. It is instantiated with the list of components to clear.

Behavior

As input component: (Rarely used) the str corresponding to the button label when the button is clicked

Your function should accept one of these types:
def predict(
	value: str | None
)
	...

As output component: string corresponding to the button label

Your function should return one of these types:
def predict(···) -> str | None
	...	
	return value

Initialization

Parameters

Shortcuts

Class Interface String Shortcut Initialization

gradio.ClearButton

"clearbutton"

Uses default values

Event Listeners

Description

Event listeners allow you to respond to user interactions with the UI components you've defined in a Gradio Blocks app. When a user interacts with an element, such as changing a slider value or uploading an image, a function is called.

Supported Event Listeners

The ClearButton component supports the following event listeners. Each event listener takes the same parameters, which are listed in the Event Parameters table below.

Listener Description

ClearButton.add(fn, ···)

Adds a component or list of components to the list of components that will be cleared when the button is clicked.

ClearButton.click(fn, ···)

Triggered when the Button is clicked.

Event Parameters

Parameters