Skip to content

Label

Text that takes its color from the theme. color is a theme token ("text", "accent", "error"…) or a hex color, and size is a named step ("xs" to "2xl") or a number. ui.muted(...) is a label with the "text_muted" color, for secondary text.

ui.label · Category: Display · Full reference →

LabelLabel
  • For any text in a themed UI: it follows theme changes, unlike a hard-coded pz.text.
  • Use ui.muted for descriptions, hints and metadata.
  • For titles use Heading.
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)

Named sizes follow the theme’s font size; a number is a size in pixels.

Label: size="xs"Label: size="xs"
size="xs"
Code
ui.label("Extra small", size="xs")
Label: size="sm"Label: size="sm"
size="sm"
Code
ui.label("Small", size="sm")
Label: size="md"Label: size="md"
size="md"
Code
ui.label("Medium", size="md")
Label: size="lg"Label: size="lg"
size="lg"
Code
ui.label("Large", size="lg")
Label: size="xl"Label: size="xl"
size="xl"
Code
ui.label("Extra large", size="xl")
Label: size="2xl"Label: size="2xl"
size="2xl"
Code
ui.label("Huge", size="2xl")
Label: color="text"Label: color="text"
color="text"
Code
ui.label("Text")
Label: ui.mutedLabel: ui.muted
ui.muted
Code
ui.muted("Muted text")
Label: color="accent"Label: color="accent"
color="accent"
Code
ui.label("Accent", color="accent")
Label: color="success"Label: color="success"
color="success"
Code
ui.label("Success", color="success")
Label: color="warning"Label: color="warning"
color="warning"
Code
ui.label("Warning", color="warning")
Label: color="error"Label: color="error"
color="error"
Code
ui.label("Error", color="error")
Label: color="#c678dd"Label: color="#c678dd"
color="#c678dd"
Code
ui.label("Any hex color", color="#c678dd")
Label: weight="normal"Label: weight="normal"
weight="normal"
Code
ui.label("Normal", weight="normal", size="lg")
Label: weight="medium"Label: weight="medium"
weight="medium"
Code
ui.label("Medium", weight="medium", size="lg")
Label: weight="semibold"Label: weight="semibold"
weight="semibold"
Code
ui.label("Semibold", weight="semibold", size="lg")
Label: weight="bold"Label: weight="bold"
weight="bold"
Code
ui.label("Bold", weight="bold", size="lg")
Label: italic=TrueLabel: italic=True
italic=True
Code
ui.label("Italic", italic=True, size="lg")
Label: mono=TrueLabel: mono=True
mono=True
Code
ui.label("def mono(): ...", mono=True)

Label has no events of its own: it shows what you give it. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.

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

Text with a theme color.

Property Default Description
content required Content: a Widget, a string or a number (converted to text).
color "text" Theme token or hex color. Defaults to "text".
size "md" "xs" (11), "sm" (12), "md" (13.5), "lg" (16), "xl" (20), "2xl" (26) or a number.
weight None Weight: "medium", "semibold", "bold"…
mono False Uses the monospace font (IBM Plex Mono).
italic False Italic.
wrap True Line wrapping.
theme None Theme to use instead of the current one (pyzed.theme.current()).
**kwargs — Passed to pyzed.text.

Full reference →

muted(content, **kwargs)

A label with the "text_muted" color.

Property Default Description
content required Content: a Widget, a string or a number (converted to text).
**kwargs — Same as label.

Full reference →