# Etiqueta

> Texto con color, tamaño y peso del tema; `muted` para texto secundario. Componente de Pyzed para GUIs de escritorio en Python, con ejemplos y API.

Source: https://albakore.github.io/pyzed/es/library/label/

:::tip[En pocas palabras]
Texto normal en la pantalla, con los colores del tema actual.
:::

Texto que toma el color del tema. `color` es un token del tema (`"text"`, `"accent"`, `"error"`…) o un color hex, y `size` es un paso con nombre (`"xs"` a `"2xl"`) o un número. `ui.muted(...)` es una etiqueta con el color `"text_muted"`, para texto secundario.

`ui.label` · Categoría: [Visualización](https://albakore.github.io/pyzed/es/library/#visualización) · [Referencia completa →](https://albakore.github.io/pyzed/es/reference/ui/#label)

**Código:**

```python
pz.column([
    ui.label("Pyzed draws native UIs with Iced."),
    ui.muted("Secondary text uses the muted color."),
    ui.label("Accent and semibold", color="accent", weight="semibold"),
    ui.label("def mono(): ...", mono=True, size="sm"),
], spacing=8)
```

## Cuándo usarlo

- Para cualquier texto en una interfaz con tema: sigue los cambios de tema, a diferencia de un `pz.text` con colores fijos.
- Usa `ui.muted` para descripciones, pistas y metadatos.
- Para títulos usa [Encabezado](https://albakore.github.io/pyzed/es/library/heading/).

## Uso

```python
import pyzed as pz
from pyzed import ui

pz.column([
    ui.label("Pyzed draws native UIs with Iced."),
    ui.muted("Secondary text uses the muted color."),
    ui.label("Accent and semibold", color="accent", weight="semibold"),
    ui.label("def mono(): ...", mono=True, size="sm"),
], spacing=8)
```

## Variantes

:::note[Sobre estas capturas]
Cada captura la graba pyzed mismo, fuera de pantalla a 2x, en One Dark o One Light según el tema de este sitio, y recortada al componente para que se vea a su tamaño real. El puntero pasa por encima, pulsa o escribe en él; un componente que no reacciona al puntero recorre algunos temas. Con movimiento reducido ves el primer fotograma. Abre **Código** bajo una captura para ver el fragmento que la dibuja; los nombres libres como `on_save` son tus propios callbacks.
:::

### Tamaño

Los tamaños con nombre siguen el tamaño de fuente del tema; un número es un tamaño en píxeles.

```python
ui.label("Extra small", size="xs")
```

```python
ui.label("Small", size="sm")
```

```python
ui.label("Medium", size="md")
```

```python
ui.label("Large", size="lg")
```

```python
ui.label("Extra large", size="xl")
```

```python
ui.label("Huge", size="2xl")
```

### Color

```python
ui.label("Text")
```

```python
ui.muted("Muted text")
```

```python
ui.label("Accent", color="accent")
```

```python
ui.label("Success", color="success")
```

```python
ui.label("Warning", color="warning")
```

```python
ui.label("Error", color="error")
```

```python
ui.label("Any hex color", color="#c678dd")
```

### Peso y estilo

```python
ui.label("Normal", weight="normal", size="lg")
```

```python
ui.label("Medium", weight="medium", size="lg")
```

```python
ui.label("Semibold", weight="semibold", size="lg")
```

```python
ui.label("Bold", weight="bold", size="lg")
```

```python
ui.label("Italic", italic=True, size="lg")
```

```python
ui.label("def mono(): ...", mono=True)
```

## Eventos

Etiqueta no tiene eventos propios: muestra lo que le das. Como todo widget, también tiene los **18 eventos comunes** (`click`, `double_click`, `right_click`, `mouse_enter`, `drag`, `key_down`, `resize`…), que se conectan con `.on(...)`: mira [Eventos](https://albakore.github.io/pyzed/es/guides/events/) y [Eventos de cada componente](https://albakore.github.io/pyzed/es/library/events/).

## Propiedades y API

### `ui.label`

```python
label(
    content,
    *,
    color='text',
    size='md',
    weight=None,
    mono=False,
    italic=False,
    wrap=True,
    theme=None,
    **kwargs,
)
```

Texto con un color del tema.

| Propiedad | Por defecto | Descripción |
| --- | --- | --- |
| `content` | *obligatorio* | Contenido: un `Widget`, un texto o un número (se convierte en texto). |
| `color` | `"text"` | Token del tema o color hex. Por defecto `"text"`. |
| `size` | `"md"` | `"xs"` (11), `"sm"` (12), `"md"` (13.5), `"lg"` (16), `"xl"` (20), `"2xl"` (26) o un número. |
| `weight` | `None` | Peso: `"medium"`, `"semibold"`, `"bold"`… |
| `mono` | `False` | Usa la fuente monoespaciada (IBM Plex Mono). |
| `italic` | `False` | Cursiva. |
| `wrap` | `True` | Ajuste de línea. |
| `theme` | `None` | Tema a usar en lugar del actual (`pyzed.theme.current()`). |
| `**kwargs` | — | Se pasan a `pyzed.text`. |

[Referencia completa →](https://albakore.github.io/pyzed/es/reference/ui/#label)

### `ui.muted`

```python
muted(content, **kwargs)
```

Un `label` con color `"text_muted"`.

| Propiedad | Por defecto | Descripción |
| --- | --- | --- |
| `content` | *obligatorio* | Contenido: un `Widget`, un texto o un número (se convierte en texto). |
| `**kwargs` | — | Los de `label`. |

[Referencia completa →](https://albakore.github.io/pyzed/es/reference/ui/#muted)

## Relacionados

- [Encabezado](https://albakore.github.io/pyzed/es/library/heading/): Títulos en seminegrita en tres niveles.
- [Kbd](https://albakore.github.io/pyzed/es/library/kbd/): Atajos de teclado dibujados como teclas, con símbolos en macOS.
- [Insignia](https://albakore.github.io/pyzed/es/library/badge/): Una pastilla pequeña para estados, versiones y contadores.
