> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
> Use this file to discover all available pages before exploring further.

# Label

> Display classification labels with confidence scores

The Label component displays classification results with confidence scores.

## Basic usage

```python theme={null}
import gradio as gr

def classify(text):
    return {"positive": 0.8, "negative": 0.2}

gr.Interface(
    fn=classify,
    inputs=gr.Textbox(),
    outputs=gr.Label()
).launch()
```

## Constructor

<ParamField path="value" type="dict[str, float] | str | float | Callable | None" default="None">
  Default value:

  * Dict of `{label: confidence}` pairs
  * Single string/number label
  * Function that returns label data
</ParamField>

<ParamField path="num_top_classes" type="int | None" default="None">
  Number of top classes to display
</ParamField>

<ParamField path="label" type="str | None" default="None">
  Label displayed above component
</ParamField>

<ParamField path="color" type="str | None" default="None">
  Background color as CSS color name or hex code
</ParamField>

<ParamField path="show_heading" type="bool" default="True">
  Whether to show the top class as heading
</ParamField>

## Events

* **change** - Triggered when value changes
* **select** - Triggered when label is selected

## Examples

### Multi-class classification

```python theme={null}
import gradio as gr

def predict(image):
    return {
        "cat": 0.6,
        "dog": 0.3,
        "bird": 0.1
    }

gr.Interface(
    fn=predict,
    inputs=gr.Image(),
    outputs=gr.Label(num_top_classes=3)
).launch()
```

### Single label

```python theme={null}
import gradio as gr

def categorize(text):
    return "Category A" if len(text) > 10 else "Category B"

gr.Interface(
    fn=categorize,
    inputs=gr.Textbox(),
    outputs=gr.Label()
).launch()
```

### With custom color

```python theme={null}
import gradio as gr

gr.Label(
    value={"success": 1.0},
    color="green"
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.