Common Event Methods
Most Gradio components support the following event listeners:change
Triggered when the value of the component changes either because of user input OR because of a function update.input
Triggered when the user changes the value of the component.click
Triggered when the component is clicked.submit
Triggered when the user presses enter in a textbox or clicks the submit button.select
Triggered when the user selects an item in the component.Event Parameters
All event methods accept the following parameters:The function to call when this event is triggered. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
List of gradio components to use as inputs. If the function takes no inputs, this should be an empty list.
List of gradio components to use as outputs. If the function returns no outputs, this should be an empty list.
Defines how the endpoint appears in the API docs. Can be a string or None. If set to a string, the endpoint will be exposed in the API docs with the given name.
Description of the API endpoint. Can be a string, None, or False.
If True, will scroll to output component on completion.
How to show the progress animation while event is running: “full” shows a spinner which covers the output component area as well as a runtime display in the upper right corner, “minimal” only shows the runtime display, “hidden” shows no progress animation at all.
If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled.
If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter.
Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True).
If False, will not run preprocessing of component data before running ‘fn’.
If False, will not run postprocessing of component data before returning ‘fn’ output to the browser.
A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event.
If “once” (default for all events except .change()) would not allow any submissions while an event is pending. If set to “multiple”, unlimited submissions are allowed while pending, and “always_last” (default for .change() and .key_up() events) would allow a second submission after the pending event is complete.
Optional frontend js method to run before running ‘fn’. Input arguments for js method are values of ‘inputs’ and ‘outputs’, return should be a list of values for output components.
If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit.
If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
Controls the visibility and accessibility of this endpoint. Can be “public” (shown in API docs and callable), “private” (hidden from API docs and not callable), or “undocumented” (hidden from API docs but callable).
Optional validation function to run before the main function. If provided, this function will be executed first with queue=False, and only if it completes successfully will the main function be called.