Introducing Gradio Clients

Watch

New to Gradio? Start here: Getting Started

See the Release History

render

@gr.render(inputs=ยทยทยท)
def hello(ยทยทยท):
   ... 

Description

The render decorator allows Gradio Blocks apps to have dynamic layouts, so that the components and event listeners in your app can change depending on custom logic. Attaching a @gr.render decorator to a function will cause the function to be re-run whenever the inputs are changed (or specified triggers are activated). The function contains the components and event listeners that will update based on the inputs.
The basic usage of @gr.render is as follows:
1. Create a function and attach the @gr.render decorator to it.
2. Add the input components to the inputs= argument of @gr.render, and create a corresponding argument in your function for each component.
3. Add all components inside the function that you want to update based on the inputs. Any event listeners that use these components should also be inside this function.

Example Usage

import gradio as gr

with gr.Blocks() as demo:
    input_text = gr.Textbox()

    @gr.render(inputs=input_text)
    def show_split(text):
        if len(text) == 0:
            gr.Markdown("## No Input Provided")
        else:
            for letter in text:
                with gr.Row():
                    text = gr.Textbox(letter)
                    btn = gr.Button("Clear")
                    btn.click(lambda: gr.Textbox(value=""), None, text)

Initialization

Parameters

Guides