Skip to main content
Components are the fundamental building blocks of Gradio interfaces. They represent inputs, outputs, and interactive elements that users can engage with in your application.

What are components?

In Gradio, components are UI elements that:
  1. Display information to users (like text, images, or charts)
  2. Collect user input (like textboxes, sliders, or file uploads)
  3. Can be both inputs and outputs in the same interface
Every component in Gradio can preprocess data for your function and postprocess results for display.

Component types

Gradio provides over 30 built-in components across several categories:

Text components

  • Textbox: Single or multi-line text input/output
  • Markdown: Display formatted text with Markdown syntax
  • HTML: Render custom HTML content
  • Code: Code editor with syntax highlighting
  • Label: Display classification results with confidence scores

Media components

  • Image: Upload, display, or edit images
  • Audio: Record or upload audio files
  • Video: Upload or display video files
  • File: Upload any file type
  • Gallery: Display multiple images in a grid

Data components

  • Dataframe: Interactive spreadsheet-like table
  • JSON: Display structured JSON data
  • HighlightedText: Show text with highlighted spans
  • Dataset: Display example inputs

Input components

  • Slider: Numeric input with min/max range
  • Number: Numeric input field
  • Checkbox: Boolean on/off toggle
  • CheckboxGroup: Select multiple options
  • Radio: Select one option from a list
  • Dropdown: Dropdown menu for selections
  • ColorPicker: Choose colors visually
  • DateTime: Select dates and times

Layout components

  • Button: Clickable button to trigger events
  • ClearButton: Clear component values
  • UploadButton: Upload files without a dedicated file component
  • State: Store values between interactions (invisible)

Visualization components

  • Plot: Display Plotly, Matplotlib, or Bokeh charts
  • BarPlot, LinePlot, ScatterPlot: Native plot components
  • Model3D: Display 3D models
  • AnnotatedImage: Images with highlighted regions

Using components

As string shortcuts

For quick prototyping, use string shortcuts:
Common shortcuts: "textbox", "image", "audio", "video", "file", "dataframe", "slider", etc.

As component instances

For more control, instantiate components directly:

Common component parameters

Most components share these parameters:

Label and info

Value

Set initial/default values:

Interactive

Control whether users can modify the component:

Visibility

Show or hide components:

Styling

Component-specific features

Textbox

Image

Slider

Dataframe

Preprocessing and postprocessing

Components automatically transform data:

Image preprocessing

Change type to control the input format:
  • type="pil" → PIL Image object
  • type="numpy" → NumPy array
  • type="filepath" → String path to file

Audio preprocessing

File handling

Updating components dynamically

Update component properties during events:
You can update any component property:

Special components

State

The State component stores data between interactions without displaying it:
State is session-specific - each user has their own isolated state.

Chatbot

The Chatbot component displays conversational messages:

Creating custom components

You can create entirely custom components using Gradio’s custom component framework. See the custom components guide for details.

Component events

Different components support different events:
  • All components: .change() - When value changes
  • Button: .click() - When clicked
  • Textbox: .submit(), .input(), .focus(), .blur()
  • File: .upload(), .delete(), .download()
  • Image: .select(), .clear()
  • Chatbot: .retry(), .undo(), .like()
See the Events concept for complete details.

See also