text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 188
values | source_page_title stringclasses 188
values |
|---|---|---|---|
", "-x", "-y", or list of strings that represent the order of the
categories.
tooltip: Literal['axis', 'none', 'all'] | list[str]
default `= "axis"`
The tooltip to display when hovering on a point. "axis" shows the values for
the axis columns, "all" shows all column values, and "none" shows no tooltip... | Initialization | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
ts: Component | list[Component] | Set[Component] | None
default `= None`
Components that are used as inputs to calculate `value` if `value` is a
function (has no effect otherwise). `value` is recalculated any time the
inputs change.
visible: bool | Literal['hidden']
default `= True`
Whether the plot... | Initialization | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
render.
preserved_by_key: list[str] | str | None
default `= "value"`
A list of parameters from this component's constructor. Inside a gr.render()
function, if a component is re-rendered with the same key, these (and only
these) parameters will be preserved in the UI (if they have been changed by
the u... | Initialization | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
`gr.LinePlot`, `gr.ScatterPlot`, and `gr.BarPlot` all share the same API. Here
is a summary of the most important features. For full details and live demos,
see the [Creating Plots](/guides/creating-plots) and [Time
Plots](/guides/time-plots) guides.
**Basic Usage with a DataFrame**
Pass a `pd.DataFrame` as the value... | Key Concepts | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
gr.ScatterPlot(df, x="weight", y="height")
@plot.select
def zoom(selection: gr.SelectData):
return gr.ScatterPlot(x_lim=[selection.index[0], selection.index[1]])
plot.double_click(lambda: gr.ScatterPlot(x_lim=None), outputs=plot)
**Realtime Data**
Use `gr.Timer` to keep ... | Key Concepts | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
Shortcuts
gradio.ScatterPlot
Interface String Shortcut `"scatterplot"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
scatter_plot_demo
| Demos | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
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 ScatterPlot component supports the foll... | Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
is should be an empty list.
api_name: str | None
default `= None`
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. If None (default), the name of the function will be used as the API
endpoin... | Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
cept a list of input values for each parameter. The lists should be
of equal length (and be up to length `max_batch_size`). The function is then
*required* to return a tuple of lists (even if there is only 1 output
component), with each list in the tuple corresponding to one output component.
max_batch_... | Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
efore running 'fn'. Input arguments for js
method are values of 'inputs' and 'outputs', return should be a list of values
for output components.
concurrency_limit: int | None | Literal['default']
default `= "default"`
If set, this is the maximum number of this event that can be running
simultaneously.... | Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
t
completes successfully will the main function be called. The validator
receives the same inputs as the main function and should return a
`gr.validate()` for each input value.
[Creating Plots](../../guides/creating-plots/)
| Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
Constructs a Gradio app automatically from a Hugging Face model/Space repo
name or a 3rd-party API provider. Note that if a Space repo is loaded, certain
high-level attributes of the Blocks (e.g. custom `css`, `js`, and `head`
attributes) will not be loaded.
| Description | https://gradio.app/docs/gradio/load | Gradio - Load Docs |
import gradio as gr
demo = gr.load("gradio/question-answering", src="spaces")
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/load | Gradio - Load Docs |
Parameters ▼
name: str
the name of the model (e.g. "google/vit-base-patch16-224") or Space (e.g.
"flax-community/spanish-gpt2"). This is the first parameter passed into the
`src` function. Can also be formatted as {src}/{repo name} (e.g.
"models/google/vit-base-patch16-224") if `src` is not provided.
... | Initialization | https://gradio.app/docs/gradio/load | Gradio - Load Docs |
DER_T | None
default `= None`
the name of the third-party (non-Hugging Face) providers to use for model
inference (e.g. "replicate", "sambanova", "fal-ai", etc). Should be one of the
providers supported by `huggingface_hub.InferenceClient`. This parameter is
only used when `src` is "models"
kwargs: <c... | Initialization | https://gradio.app/docs/gradio/load | Gradio - Load Docs |
The gr.SelectData class is a subclass of gr.EventData that specifically
carries information about the `.select()` event. When gr.SelectData is added
as a type hint to an argument of an event listener method, a gr.SelectData
object will automatically be passed as the value of that argument. The
attributes of this object... | Description | https://gradio.app/docs/gradio/selectdata | Gradio - Selectdata Docs |
import gradio as gr
with gr.Blocks() as demo:
table = gr.Dataframe([[1, 2, 3], [4, 5, 6]])
gallery = gr.Gallery([("cat.jpg", "Cat"), ("dog.jpg", "Dog")])
textbox = gr.Textbox("Hello World!")
statement = gr.Textbox()
def on_select(evt: gr.SelectData):
ret... | Example Usage | https://gradio.app/docs/gradio/selectdata | Gradio - Selectdata Docs |
Parameters ▼
index: int | tuple[int, int]
The index of the selected item. Is a tuple if the component is two dimensional
or selection is a range.
value: Any
The value of the selected item.
row_value: list[float | str]
The value of the entire row that the selected item ... | Attributes | https://gradio.app/docs/gradio/selectdata | Gradio - Selectdata Docs |
gallery_selectionstictactoe
| Demos | https://gradio.app/docs/gradio/selectdata | Gradio - Selectdata Docs |
Creates a gallery component that allows displaying a grid of images or
videos, and optionally captions. If used as an input, the user can upload
images or videos to the gallery. If used as an output, the user can click on
individual images or videos to view them at a higher resolution.
| Description | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
**Using Gallery as an input component.**
How Gallery will pass its value to your function:
Type: `list[tuple[str, str | None]] | list[tuple[PIL.Image.Image, str | None]] | list[tuple[np.ndarray, str | None]] | None`
Passes the list of images or videos as:
* a list of (media, caption) tuples
* a list of (media,... | Behavior | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
Parameters ▼
value: list[np.ndarray | PIL.Image.Image | str | Path | tuple] | Callable | None
default `= None`
List of images or videos to display in the gallery by default. If a function
is provided, the function will be called each time the app loads to set the
initial value of this component.
... | Initialization | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
). `value` is recalculated any time the
inputs change.
show_label: bool | None
default `= None`
if True, will display label.
container: bool
default `= True`
If True, will place the component in a container - providing some extra
padding around the border.
scale: int ... | Initialization | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
with the same key across re-renders are treated as
the same component, not a new component. Properties set in 'preserved_by_key'
are not reset across a re-render.
preserved_by_key: list[str] | str | None
default `= "value"`
A list of parameters from this component's constructor. Inside a gr.render()
f... | Initialization | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
`= None`
CSS object-fit property for the thumbnail images in the gallery. Can be
"contain", "cover", "fill", "none", or "scale-down".
buttons: list[Literal['share', 'download', 'fullscreen'] | Button] | None
default `= None`
A list of buttons to show in the top right corner of the component. Valid
op... | Initialization | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
upload images from when this component is
used as an input. Valid options are "upload", "webcam", and "clipboard".
"upload" allows the user to upload files from their computer, "webcam" allows
the user to take a photo or video using their webcam, and "clipboard" allows
the user to paste an image or video from their cl... | Initialization | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
Shortcuts
gradio.Gallery
Interface String Shortcut `"gallery"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
fake_gangif_maker
| Demos | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
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 Gallery component supports the followin... | Event Listeners | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
fn: Callable | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. 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 e... | Event Listeners | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
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
show_progress_on: Component | list[Component] | None
default `= None`
Component... | Event Listeners | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
this listener is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to... | Event Listeners | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
be "public"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: ... | Event Listeners | https://gradio.app/docs/gradio/gallery | Gradio - Gallery Docs |
Creates an image component that can be used to upload images (as an input)
or display images (as an output).
| Description | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
**Using Image as an input component.**
How Image will pass its value to your function:
Type: `np.ndarray | PIL.Image.Image | str | None`
Passes the uploaded image as a `numpy.array`, `PIL.Image` or `str` filepath
depending on `type`.
Example Code
import gradio as gr
def pred... | Behavior | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
Parameters ▼
value: str | PIL.Image.Image | np.ndarray | Callable | None
default `= None`
A `PIL.Image`, `numpy.array`, `pathlib.Path`, or `str` filepath or URL for the
default value that Image component is going to take. If a function is
provided, the function will be called each time the app loads t... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
erred
from the image file type (e.g. "RGBA" for a .png image, "RGB" in most other
cases).
sources: list[Literal['upload', 'webcam', 'clipboard']] | Literal['upload', 'webcam', 'clipboard'] | None
default `= None`
List of sources for the image. "upload" creates a box where user can drop an
image file, ... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
calculate `value` if `value` is a
function (has no effect otherwise). `value` is recalculated any time the
inputs change.
show_label: bool | None
default `= None`
if True, will display label.
buttons: list[Literal['download', 'share', 'fullscreen'] | Button] | None
default `= None`
... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
ovided, this is inferred based on whether the
component is used as an input or output.
visible: bool | Literal['hidden']
default `= True`
If False, component will be hidden. If "hidden", component will be visually
hidden and not take up space in the layout but still exist in the DOM
st... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
s
provided during constructor.
webcam_options: WebcamOptions | None
default `= None`
placeholder: str | None
default `= None`
Custom text for the upload area. Overrides default upload messages when
provided. Accepts new lines and `` to designate a heading.
watermark: W... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
Shortcuts
gradio.Image
Interface String Shortcut `"image"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
The `type` parameter controls the format of the data passed to your Python
function. Choosing the right type avoids unnecessary conversions in your code:
`type`| Your function receives| Shape / Format| Best for
---|---|---|---
`"numpy"` (default)| `numpy.ndarray`| `(height, width, 3)`, dtype `uint8`,
values 0–255|... | Understanding Image Types | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
The `gr.Image` component can process or display any image format that is
[supported by the PIL
library](https://pillow.readthedocs.io/en/stable/handbook/image-file-
formats.html), including animated GIFs. In addition, it also supports the SVG
image format.
When the `gr.Image` component is used as an input component, t... | `GIF` and `SVG` Image Formats | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
sepia_filterfake_diffusion
| Demos | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
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 Image component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
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.
inputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List o... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list of components to show the progress animation on. If None,
will show the progress animation on all of the output components.
queue: bool
default `= True`
If True, will place the r... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
n (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
trigger_mode: Literal['once', 'multiple', 'always_last'] | None
default `= None`
If "once" (default for all events except `.change()`) would not allow any
submissions while an ev... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
nd via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None
default `= None`
stream_every: float
default `= 0.5`
key: int | str | tuple[int | str, ...] | None
default `= None`
A unique key for this event listener to be... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
Helper Classes | https://gradio.app/docs/gradio/image | Gradio - Image Docs | |
gradio.WebcamOptions(···)
Description
A dataclass for specifying options for the webcam tool in the ImageEditor
component. An instance of this class can be passed to the `webcam_options`
parameter of `gr.ImageEditor`.
Initialization
Parameters ▼
mirror: bool
default `= True`
If True, the webcam wi... | Webcam Options | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
Creates a textarea for users to enter string input or display string output
and also allows for the uploading of multimedia files.
| Description | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
**Using MultimodalTextbox as an input component.**
How MultimodalTextbox will pass its value to your function:
Type: `MultimodalValue | None`
Passes text value and list of file(s) as a `dict` into the function.
Example Code
import gradio as gr
def predict(
value:... | Behavior | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
Parameters ▼
value: str | dict[str, str | list] | Callable | None
default `= None`
Default value to show in MultimodalTextbox. A string value, or a dictionary of
the form {"text": "sample text", "files": [{path: "files/file.jpg", orig_name:
"file.jpg", url: "http://image_url.jpg", size: 100}]}. If a f... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
e`
the label for this component, displayed above the component if `show_label` is
`True` and is also used as the header if there are a table of examples for
this component. If None and used in a `gr.Interface`, the label will be the
name of the parameter this component corresponds to.
info: str | I18nD... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
cted first.
interactive: bool | None
default `= None`
if True, will be rendered as an editable textbox; if False, editing will be
disabled. If not provided, this is inferred based on whether the component is
used as an input or output.
visible: bool | Literal['hidden']
default `= True... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
rved_by_key: list[str] | str | None
default `= "value"`
A list of parameters from this component's constructor. Inside a gr.render()
function, if a component is re-rendered with the same key, these (and only
these) parameters will be preserved in the UI (if they have been changed by
the user or an event listener) ins... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
Shortcuts
gradio.MultimodalTextbox
Interface String Shortcut `"multimodaltextbox"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
chatbot_multimodal
| Demos | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
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 MultimodalTextbox component supports th... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
d of the media playing
in the MultimodalTextbox.
Event Parameters
Parameters ▼
fn: Callable | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. Each parameter of the function corresponds to one... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
ss: Literal['full', 'minimal', 'hidden']
default `= "full"`
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... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
dict[str, Any] | list[dict[str, Any]] | None
default `= None`
A list of other events to cancel when this listener is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generat... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
'undocumented']
default `= "public"`
controls the visibility and accessibility of this endpoint. Can be "public"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.loa... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
Tab (or its alias TabItem) is a layout element. Components defined within
the Tab will be visible when this tab is selected tab.
| Description | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
with gr.Blocks() as demo:
with gr.Tab("Lion"):
gr.Image("lion.jpg")
gr.Button("New Lion")
with gr.Tab("Tiger"):
gr.Image("tiger.jpg")
gr.Button("New Tiger")
| Example Usage | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
Parameters ▼
label: str | I18nData | None
default `= None`
The visual label for the tab
visible: bool | Literal['hidden']
default `= True`
If False, Tab will be hidden.
interactive: bool
default `= True`
If False, Tab will not be clickable.
id: int |... | Initialization | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
Methods | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs | |
%20Copyright%202022%20Fonticons,%20Inc.... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20318.... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
le | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. 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 ... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
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
show_progress_on: Component | list[Component] | None
default `= None`
Component or list o... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
ner is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
c"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20318.... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
le | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. 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 ... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
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
show_progress_on: Component | list[Component] | None
default `= None`
Component or list o... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
ner is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
c"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
Creates a component with arbitrary HTML. Can include CSS and JavaScript to
create highly customized and interactive components.
| Description | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
**Using HTML as an input component.**
How HTML will pass its value to your function:
Type: `str | None`
(Rarely used) passes the HTML as a `str`.
Example Code
import gradio as gr
def predict(
value: str | None
):
process value from the HTML co... | Behavior | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
Parameters ▼
value: Any | Callable | None
default `= None`
The HTML content in the ${value} tag in the html_template. For example, if
html_template="<p>${value}</p>" and value="Hello, world!", the component will
render as `"<p>Hello, world!</p>"`.
label: str | I18nData | None
default ... | Initialization | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
()`. The `trigger` function can be used to trigger
events, such as `trigger('click')`. The value and other props can be edited
through `props`, e.g. `props.value = "new value"` which will re-render the
HTML template. If `server_functions` is provided, a `server` object is also
available in `js_on_load`, where each func... | Initialization | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
visible: bool | Literal['hidden']
default `= True`
If False, component will be hidden. If "hidden", component will be visually
hidden and not take up space in the layout but still exist in the DOM
elem_id: str | None
default `= None`
An optional string that is assigned as the id of ... | Initialization | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
`= None`
The maximum height of the component, specified in pixels if a number is
passed, or in CSS units if a string is passed. If content exceeds the height,
the component will scroll.
container: bool
default `= False`
If True, the HTML component will be displayed in a container. Default is
False.
... | Initialization | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
props: Any
Additional keyword arguments to pass into the HTML and CSS templates for
rendering.
| Initialization | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
Shortcuts
gradio.HTML
Interface String Shortcut `"html"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
super_html
| Demos | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
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 HTML component supports the following e... | Event Listeners | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
, ···)
This listener is triggered when the user reaches the end of the media playing
in the HTML.
HTML.start_recording(fn, ···)
This listener is triggered when the user starts recording with the HTML.
HTML.pause_recording(fn, ···)
This listener is triggered when the user pauses recordin... | Event Listeners | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
ta.index and SelectData.value. See
SelectData documentation on how to use this event data.
HTML.option_select(fn, ···)
This listener is triggered when the user clicks on an option from within the
HTML. This event has SelectData of type gradio.SelectData that carries
information, accessible through Selec... | Event Listeners | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
e
as a FileData object. See EventData documentation on how to use this event
data
HTML.copy(fn, ···)
This listener is triggered when the user copies content from the HTML. Uses
event data gradio.CopyData to carry information about the copied content. See
EventData documentation on how to use this event ... | Event Listeners | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
he function's docstring will be used as the API
endpoint description. If False, then no description will be displayed in the
API docs.
scroll_to_output: bool
default `= False`
If True, will scroll to output component on completion
show_progress: Literal['full', 'minimal', 'hidden']
de... | Event Listeners | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
g 'fn'
(e.g. leaving it as a base64 string if this method is called with the `Image`
component).
postprocess: bool
default `= True`
If False, will not run postprocessing of component data before returning 'fn'
output to the browser.
cancels: dict[str, Any] | list[dict[str, Any]] | None... | Event Listeners | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
1 by default).
concurrency_id: str | None
default `= None`
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.
api_visibility: Literal['public', 'private', 'undocumented']
default `= "public"`
contr... | Event Listeners | https://gradio.app/docs/gradio/html | Gradio - Html Docs |
The gr.UndoData class is a subclass of gr.Event data that specifically
carries information about the `.undo()` event. When gr.UndoData is added as a
type hint to an argument of an event listener method, a gr.UndoData object
will automatically be passed as the value of that argument. The attributes of
this object contai... | Description | https://gradio.app/docs/gradio/undodata | Gradio - Undodata Docs |
import gradio as gr
def undo(retry_data: gr.UndoData, history: list[gr.MessageDict]):
history_up_to_retry = history[:retry_data.index]
return history_up_to_retry
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
chatbot.undo(undo, chatbot, chatbot)
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/undodata | Gradio - Undodata Docs |
Parameters ▼
index: int | tuple[int, int]
The index of the user message that should be undone.
value: Any
The value of the user message that should be undone.
| Attributes | https://gradio.app/docs/gradio/undodata | Gradio - Undodata Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.