What are components?
In Gradio, components are UI elements that:- Display information to users (like text, images, or charts)
- Collect user input (like textboxes, sliders, or file uploads)
- Can be both inputs and outputs in the same interface
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:"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
Dropdown
Dataframe
Preprocessing and postprocessing
Components automatically transform data:Image preprocessing
type to control the input format:
type="pil"→ PIL Image objecttype="numpy"→ NumPy arraytype="filepath"→ String path to file
Audio preprocessing
File handling
Updating components dynamically
Update component properties during events: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 also
- Interface - Using components in Interface
- Blocks - Using components in Blocks
- Events - Component event listeners
- Component Reference - Detailed documentation for each component