text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 190
values | source_page_title stringclasses 190
values |
|---|---|---|---|
Parameters ▼
track_tqdm: bool
default `= False`
If True, the Progress object will track any tqdm.tqdm iterations with the tqdm
library in the function.
| Initialization | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
Methods | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs | |
%20Copyright%202022%20Fonticons,%20Inc.... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
20512'%3e%3c!--!%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... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
None if unknown. If None, hides progress bar.
desc: str | None
default `= None`
description to display.
total: int | float | None
default `= None`
estimated total number of steps.
unit: str
default `= "steps"`
unit of iterations.
| __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
2'%3e%3c!--!%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%2... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
total number of steps.
unit: str
default `= "steps"`
unit of iterations.
[Progress Bars](../../guides/progress-bars/)
| tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
20512'%3e%3c!--!%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... | __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
None if unknown. If None, hides progress bar.
desc: str | None
default `= None`
description to display.
total: int | float | None
default `= None`
estimated total number of steps.
unit: str
default `= "steps"`
unit of iterations.
| __call__ | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
2'%3e%3c!--!%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%2... | tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
total number of steps.
unit: str
default `= "steps"`
unit of iterations.
| tqdm | https://gradio.app/docs/gradio/progress | Gradio - Progress Docs |
The gr.CopyData class is a subclass of gr.EventData that specifically
carries information about the `.copy()` event. When gr.CopyData is added as a
type hint to an argument of an event listener method, a gr.CopyData object
will automatically be passed as the value of that argument. The attributes of
this object contain... | Description | https://gradio.app/docs/gradio/copydata | Gradio - Copydata Docs |
import gradio as gr
def on_copy(copy_data: gr.CopyData):
return f"Copied text: {copy_data.value}"
with gr.Blocks() as demo:
textbox = gr.Textbox("Hello World!")
copied = gr.Textbox()
textbox.copy(on_copy, None, copied)
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/copydata | Gradio - Copydata Docs |
Parameters ▼
value: Any
The value that was copied.
| Attributes | https://gradio.app/docs/gradio/copydata | Gradio - Copydata Docs |
The gr.DeletedFileData class is a subclass of gr.EventData that
specifically carries information about the `.delete()` event. When
gr.DeletedFileData is added as a type hint to an argument of an event listener
method, a gr.DeletedFileData object will automatically be passed as the value
of that argument. The attributes... | Description | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
import gradio as gr
def test(delete_data: gr.DeletedFileData):
return delete_data.file.path
with gr.Blocks() as demo:
files = gr.File(file_count="multiple")
deleted_file = gr.File()
files.delete(test, None, deleted_file)
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
Parameters ▼
file: FileData
The file that was deleted, as a FileData object. The str path to the file can
be retrieved with the .path attribute.
| Attributes | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
file_component_events
| Demos | https://gradio.app/docs/gradio/deletedfiledata | Gradio - Deletedfiledata Docs |
A base class for defining methods that all input/output components should
have.
| Description | https://gradio.app/docs/gradio/state | Gradio - State Docs |
**Using State as an input component.**
How State will pass its value to your function:
Type: `Any`
Passes a value of arbitrary type through.
Example Code
import gradio as gr
def predict(
value: Any
):
process value from the State component
... | Behavior | https://gradio.app/docs/gradio/state | Gradio - State Docs |
Parameters ▼
value: Any
default `= None`
the initial value (of arbitrary type) of the state. The provided argument is
deepcopied. If a callable is provided, the function will be called whenever
the app loads to set the initial value of the state.
render: bool
default `= True`
should ... | Initialization | https://gradio.app/docs/gradio/state | Gradio - State 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 State component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
e 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
endpoint.
api_description: str | None | Literal[False]
default `= None`
Description of the API endpoint. Can be... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
. 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_size: int
default `= 4`
Maximum number of inputs to batch together if this is called from the queue
(only relevant if ba... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
as arguments; raw code can access them through `arguments`. Return a list of
values for the 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. Can be set to None to mean no con... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
main function be called. The validator
receives the same inputs as the main function, including the same keyword
arguments when `inputs_kwargs` is used, so its signature must accept those
keyword names. It should return a `gr.validate()` for each input value.
inputs_kwargs: dict[str, Component | BlockCo... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
Component to select a date and (optionally) a time.
| Description | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
**Using DateTime as an input component.**
How DateTime will pass its value to your function:
Type: `str | float | datetime | None`
Passes text value as a `str` into the function.
Example Code
import gradio as gr
def predict(
value: str | float | datetime | None
... | Behavior | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
Parameters ▼
value: float | str | datetime | None
default `= None`
default value for datetime.
include_time: bool
default `= True`
If True, the component will include time selection. If False, only date
selection will be available.
type: Literal['timestamp', 'datetime... | Initialization | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
nents. For example if Components A and
B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide
as B. Should be an integer. scale applies in Rows, and to top-level Components
in Blocks where fill_height=True.
min_width: int
default `= 160`
minimum pixel width, will wrap if not suf... | Initialization | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
y have been changed by
the user or an event listener) instead of re-rendered based on the values
provided during constructor.
buttons: list[Button] | None
default `= None`
A list of gr.Button() instances to show in the top right corner of the
component. Custom buttons will appear in the toolbar with t... | Initialization | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
Shortcuts
gradio.DateTime
Interface String Shortcut `"datetime"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/datetime | Gradio - Datetime 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 DateTime component supports the followi... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
returns no
outputs, this 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 u... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
ning that it
should accept 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.
... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
end JavaScript to run before 'fn', provided as either a function
or a raw code string. A function receives the values of 'inputs' and 'outputs'
as arguments; raw code can access them through `arguments`. Return a list of
values for the output components.
concurrency_limit: int | None | Literal['default'... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
un 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. The validator
receives the same inputs as the main function, including the same keyword
arguments when `inputs_kwargs` is used, so its signature must a... | Event Listeners | https://gradio.app/docs/gradio/datetime | Gradio - Datetime Docs |
Creates a numeric field for user to enter numbers as input or display
numeric output.
| Description | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
**Using Number as an input component.**
How Number will pass its value to your function:
Type: `float | int | None`
Passes field value as a `float` or `int` into the function, depending on
`precision`.
Example Code
import gradio as gr
def predict(
value: float | ... | Behavior | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
Parameters ▼
value: float | Callable | None
default `= None`
default value. If None, the component will be empty and show the `placeholder`
if is set. If no `placeholder` is set, the component will show 0. If a
function is provided, the function will be called each time the app loads to
set the initia... | Initialization | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
e`
relative size compared to adjacent Components. For example if Components A and
B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide
as B. Should be an integer. scale applies in Rows, and to top-level Components
in Blocks where fill_height=True.
min_width: int
default `= 160... | Initialization | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
_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()
function, if a component is re-rendered with the same key, these (and only
these) parameters will be preserved in the UI (if... | Initialization | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
Shortcuts
gradio.Number
Interface String Shortcut `"number"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
tax_calculatorblocks_simple_squares
| Demos | https://gradio.app/docs/gradio/number | Gradio - Number 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 Number component supports the following... | Event Listeners | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
io.components to use as inputs. If the function takes no inputs,
this should be an empty list.
outputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, thi... | Event Listeners | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
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 None, will use the queue setting of the gradio app.
batch: bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should acc... | Event Listeners | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
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.
js: str | Literal[True] | None
default `= None`
Optional frontend JavaScript to run b... | Event Listeners | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
t | str, ...] | None
default `= None`
A unique key for this event listener to be used in @gr.render(). If set, this
value identifies an event as identical across re-renders when the key is
identical.
validator: Callable | None
default `= None`
Optional validation function to run before the main func... | Event Listeners | https://gradio.app/docs/gradio/number | Gradio - Number Docs |
Creates a component allows users to upload or view 3D Model files (.obj,
.glb, .stl, .gltf, .splat, or .ply).
| Description | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
**Using Model3D as an input component.**
How Model3D will pass its value to your function:
Type: `str | None`
Passes the uploaded file as a `str` filepath to the function.
Example Code
import gradio as gr
def predict(
value: str | None
):
proc... | Behavior | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
Parameters ▼
value: str | Callable | None
default `= None`
path to (.obj, .glb, .stl, .gltf, .splat, or .ply) file to show in model3D
viewer. If a function is provided, the function will be called each time the
app loads to set the initial value of this component.
display_mode: Literal... | Initialization | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
e a positive float, increase this value
to make panning faster, decrease to make it slower. Affects the panSensibility
property of the camera.
height: int | str | None
default `= None`
The height of the model3D component, specified in pixels if a number is
passed, or in CSS units if a string is passed... | Initialization | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
will wrap if not sufficient screen space to satisfy this
value. If a certain scale value results in this Component being narrower than
min_width, the min_width parameter will be respected first.
interactive: bool | None
default `= None`
if True, will allow users to upload a file; if False, can only b... | Initialization | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
(if they have been changed by
the user or an event listener) instead of re-rendered based on the values
provided during constructor.
buttons: list[Button] | None
default `= None`
A list of gr.Button() instances to show in the top right corner of the
component. Custom buttons will appear in the toolbar... | Initialization | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
Shortcuts
gradio.Model3D
Interface String Shortcut `"model3d"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/model3d | Gradio - Model3D 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 Model3D component supports the followin... | Event Listeners | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
tion takes no inputs,
this should be an empty list.
outputs: Component | BlockContext | list[Component | BlockContext] | Set[Component | BlockContext] | None
default `= None`
List of gradio.components to use as outputs. If the function returns no
outputs, this should be an empty list.
... | Event Listeners | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
d.
If False, will not put this event on the queue, even if the queue has been
enabled. If None, will use the queue setting of the gradio app.
batch: bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
should accept a list of input values for each paramet... | Event Listeners | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
ubmissions 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.
js: str | Literal[True] | None
default `= None`
Optional frontend JavaScript to run before 'fn', provided as either a function
o... | Event Listeners | https://gradio.app/docs/gradio/model3d | Gradio - Model3D Docs |
nique key for this event listener to be used in @gr.render(). If set, this
value identifies an event as identical across re-renders when the key is
identical.
validator: Callable | None
default `= None`
Optional validation function to run before the main function. If provided,
this function will be ex... | Event Listeners | https://gradio.app/docs/gradio/model3d | Gradio - Model3D 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 |
o 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 |
rovided, 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
s... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
es
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: ... | 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 |
dio 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
default `= None`
stream_every: float
default `= 0.5`
key: int | str | tu... | 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 user to enter string input or display string output.
| Description | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
**Using Textbox as an input component.**
How Textbox will pass its value to your function:
Type: `str | None`
Passes text value as a `str` into the function.
Example Code
import gradio as gr
def predict(
value: str | None
):
process value from... | Behavior | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
Parameters ▼
value: str | I18nData | Callable | None
default `= None`
text to show in textbox. If a function is provided, the function will be
called each time the app loads to set the initial value of this component.
type: Literal['text', 'password', 'email']
default `= "text"`
The ... | Initialization | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
e regular interval for the reset Timer.
inputs: 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.
show_labe... | Initialization | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
targeting CSS styles.
autofocus: bool
default `= False`
If True, will focus on the textbox when the page loads. Use this carefully, as
it can cause usability issues for sighted and non-sighted users.
autoscroll: bool
default `= True`
If True, will automatically scroll to the bottom o... | Initialization | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
True. Can only be changed if `type` is "text".
rtl: bool
default `= False`
If True and `type` is "text", sets the direction of the text to right-to-left
(cursor appears on the left of the text). Default is False, which renders
cursor on the right.
buttons: list[Literal['copy'] | Button... | Initialization | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
InputHTMLAttributes(autocorrect="off", spellcheck=False) to disable
autocorrect and spellcheck.
| Initialization | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
Shortcuts
gradio.Textbox
Interface String Shortcut `"textbox"`
Initialization Uses default values
gradio.TextArea
Interface String Shortcut `"textarea"`
Initialization Uses lines=7
| Shortcuts | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
Multi-line text input
By default, `gr.Textbox` renders as a single-line input. For longer text such
as paragraphs or code, set `lines` to show multiple rows and optionally
`max_lines` to cap the height:
import gradio as gr
def summarize(text):
return f"Received {len(text.split())} words... | Common Patterns | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
hello_worlddiff_textssentence_builder
| Demos | https://gradio.app/docs/gradio/textbox | Gradio - Textbox 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 Textbox component supports the followin... | Event Listeners | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
t data gradio.CopyData to carry information about the copied content. See
EventData documentation on how to use this event data
Event Parameters
Parameters ▼
fn: Callable | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning... | Event Listeners | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
True, will scroll to output component on completion
show_progress: 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, "m... | Event Listeners | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
ent data before returning 'fn'
output to the browser.
cancels: 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 o... | Event Listeners | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
ncurrency group. Events with the same
concurrency_id will be limited by the lowest set concurrency_limit.
api_visibility: Literal['public', 'private', 'undocumented']
default `= "public"`
controls the visibility and accessibility of this endpoint. Can be "public"
(shown in API docs and callable by cli... | Event Listeners | https://gradio.app/docs/gradio/textbox | Gradio - Textbox Docs |
The gr.RetryData class is a subclass of gr.Event data that specifically
carries information about the `.retry()` event. When gr.RetryData is added as
a type hint to an argument of an event listener method, a gr.RetryData object
will automatically be passed as the value of that argument. The attributes of
this object co... | Description | https://gradio.app/docs/gradio/retrydata | Gradio - Retrydata Docs |
import gradio as gr
def retry(retry_data: gr.RetryData, history: list[gr.MessageDict]):
history_up_to_retry = history[:retry_data.index]
new_response = ""
for token in api.chat_completion(history):
new_response += token
yield history + [new_response]
wit... | Example Usage | https://gradio.app/docs/gradio/retrydata | Gradio - Retrydata Docs |
Parameters ▼
index: int | tuple[int, int]
The index of the user message that should be retried.
value: Any
The value of the user message that should be retried.
[Chatbot Specific Events](../../guides/chatbot-specific-events/)
| Attributes | https://gradio.app/docs/gradio/retrydata | Gradio - Retrydata Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.