jayavibhav's picture
Upload folder using huggingface_hub
c6b9c0b verified

A newer version of the Gradio SDK is available: 5.34.2

Upgrade
metadata
tags:
  - gradio-custom-component
  - SimpleTextbox
title: gradio_iframecomponent
short_description: iframe
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py

gradio_iframecomponent

Static Badge

iframe

Installation

pip install gradio_iframecomponent

Usage

import gradio as gr
from gradio_iframecomponent import IFrame

def create_demo():
    with gr.Blocks() as demo:
        gr.Markdown("# IFrame Component Demo")
        
        iframe = IFrame(
            label="Web Page Viewer",
            value="https://www.gradio.app",
            interactive=True,
            height=500
        )
        
        url_input = gr.Textbox(
            label="Enter URL",
            placeholder="https://example.com"
        )
        
        load_btn = gr.Button("Load URL")
        
        load_btn.click(
            fn=lambda url: url,
            inputs=url_input,
            outputs=iframe
        )
    
    return demo

if __name__ == "__main__":
    demo = create_demo()
    demo.launch()

IFrame

Initialization

name type default description
value
str
"" None
src
str | None
None None
width
str | int
"100%" None
height
str | int
400 None
sandbox
str | None
None None
interactive
bool
True None
visible
bool
True None
elem_id
str | None
None None
elem_classes
list[str] | str | None
None None
render
bool
True None
label
str | None
None None
show_label
bool
True None

Events

name description
change Triggered when the value of the IFrame changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.
input This listener is triggered when the user changes the value of the IFrame.

User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

  • When used as an Input, the component only impacts the input signature of the user function.
  • When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

def predict(
    value: str | None
) -> str | None:
    return value