Catalog
huggingface/huggingface-gradio

huggingface

huggingface-gradio

Build Gradio web UIs and demos in Python. Use when creating, modifying, debugging, or answering questions about Gradio and its capabilities, components, event listeners, or layouts.

NewUpdated Nov 24, 2026

Gradio

Gradio is a Python library for building interactive web UIs and ML demos. This skill covers the core API, patterns, and examples.

References

  • references/examples.md - Illustrative examples showcasing the core Gradio API.
  • references/api-signatures.md - API signatures of commonly used components.
  • references/event-listeners.md - API signatures of events supported by each component.

Guides

Detailed guides on specific topics (read these when relevant):

Core Patterns

Interface (high-level): wraps a function with input/output components.

import gradio as gr

def greet(name):
    return f"Hello {name}!"

gr.Interface(fn=greet, inputs="text", outputs="text").launch()

Blocks (low-level): flexible layout with explicit event wiring.

import gradio as gr

with gr.Blocks() as demo:
    name = gr.Textbox(label="Name")
    output = gr.Textbox(label="Greeting")
    btn = gr.Button("Greet")
    btn.click(fn=lambda n: f"Hello {n}!", inputs=name, outputs=output)

demo.launch()

ChatInterface: high-level wrapper for chatbot UIs.

import gradio as gr

def respond(message, history):
    return f"You said: {message}"

gr.ChatInterface(fn=respond).launch()

Workflow: builds a visual, node-based pipeline from Hugging Face Spaces, models, datasets, and Python functions. gr.Workflow is a standalone app, so do not create it inside a gr.Blocks context.

import gradio as gr

def clean(text: str) -> str:
    return text.strip().lower()

def tag(text: str) -> str:
    return f"[processed] {text}"

gr.Workflow(
    bind={"clean": clean, "tag": tag},
    edges=[("clean", "tag")],
).launch()

The graph is saved to workflow.json next to the script (or the path passed as graph=), and you can write or edit that file directly to build workflows programmatically. It has references (inputs), operators (processing steps) and subjects (outputs), connected by edges between typed ports (image, audio, video, text, number, boolean, gallery, file, json, model3d, any). Operator kind is one of:

  • "space": a Gradio Space, with space_id and endpoint
  • "model": a Hugging Face model via Inference Providers, with model_id and an endpoint such as text_to_image
  • "dataset": one row of a Hub dataset per run, with dataset_id, dataset_config and dataset_split
  • "fn": a Python function, whose fn value matches a key in bind=

edges= only wires bound Python functions, and is ignored once the workflow file exists. See the Workflows guide for the full JSON format, deployment and ZeroGPU quotas.

Custom HTML Components

If a task requires significant customization of an existing component or a component that doesn't exist in Gradio, you can create one with gr.HTML. It supports html_template (with ${} JS expressions and {{}} Handlebars syntax), css_template for scoped styles, and js_on_load for interactivity — where props.value updates the component value and trigger('event_name') fires Gradio events. For reuse, subclass gr.HTML and define api_info() for API/MCP support.

See the full guide as well as example in references/examples.md

Server Mode

Use gr.Server instead of gr.Blocks when the users requests any of the following:

  • Completely custom UI (your own HTML, React, Svelte, etc.) powered by Gradio's backend.
  • Full control of FastAPI server (custom GET/POST routes, middleware, dependency injection) alongside Gradio API endpoints

See the full guide and example in references/examples.md.

If the user's use case can be handled by Gradio's built-in components or customizable HTML components, prefer not to use gr.Server.

MCP Server

Any Gradio app can also be an MCP server: demo.launch(mcp_server=True) (requires pip install "gradio[mcp]"). Each API endpoint becomes an MCP tool, served at /gradio_api/mcp/, with the tool description and argument schema taken from the function's docstring and type hints, so write both carefully.

See the full guide.

Files4
4 files · 50.4 KB

Select a file to preview

Overall Score

88/100

Grade

A

Excellent

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

95

Quality

87

Clarity

86

Completeness

85

Summary

This skill teaches AI agents how to build interactive web UIs and ML demos using the Gradio Python library. It covers core patterns (Interface, Blocks, ChatInterface, Workflow), component APIs, event listeners, and advanced features like custom HTML components, server mode, and MCP integration. The skill is structured as reference documentation with examples and API signatures, enabling agents to create, modify, and debug Gradio applications.

Detected Capabilities

code example generationAPI reference consultationcomponent selection guidanceevent wiring patternslayout designmarkdown documentation

Trigger Keywords

Phrases that agents use to match this skill to user intent.

build gradio uicreate web demogradio blocks layoutgradio event listenerschatbot interfaceml workflow pipelinecustom html componentgradio server mode

Referenced Domains

External domains referenced in skill content, detected by static analysis.

cdn.jsdelivr.netupload.wikimedia.orgwww.apache.orgwww.gradio.app

Use Cases

  • Build a text classification web UI with Gradio Blocks
  • Create an interactive chatbot demo with ChatInterface
  • Design a multi-step ML pipeline using Workflow nodes
  • Add custom styling and interactivity with HTML components
  • Debug event listener configurations in a Gradio app
  • Convert a Gradio app into an MCP server
  • Build a custom UI with gr.Server for full FastAPI control

Quality Notes

  • Excellent structured reference with clear separation of concerns: core patterns, guides, API signatures, and working examples
  • All 23 supporting code examples are complete, runnable, and illustrate different Gradio features (Interface, Blocks, ChatInterface, Workflow, Server mode)
  • Comprehensive component API signatures with full parameter documentation (Textbox, Number, Slider, Image, Audio, Video, Chatbot, HTML, etc.)
  • Event listener documentation is complete with signature template and exhaustive component-to-event mapping
  • Workflow documentation clearly explains node types (space, model, dataset, fn) and graph structure (references, operators, subjects, edges, ports)
  • Custom HTML component guidance includes practical patterns (templating with ${} and {{}}, CSS scoping, JS interactivity via props.value and trigger())
  • Guides cover both beginner (Quickstart, Interface) and advanced (Streaming, Server Mode, MCP) use cases with external links
  • Minor: Some inline code examples in SKILL.md could benefit from brief inline comments explaining intent (e.g., Workflow example doesn't explain why edges are ignored after graph exists)
Model: claude-haiku-4-5-20251001Analyzed: Nov 24, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

  1. v2.0

    Contract changed: description

    ✦ AIExpands scope to cover debugging and capability questions; adds API reference files and new Gradio guides (Workflows, Server Mode, MCP Server).

    triggering2026-11-24

    LATEST
  2. v1.0

    2026-07-11

    View This VersionInitial version

Use huggingface/huggingface-gradio in your dev environment

Command Palette

Search for a command to run...