Skip to content

Chip

A small rounded tag. With on_press it acts as a filter you can toggle (selected=True highlights it), and with on_remove it shows a close button, as in a list of tags.

ui.chip · Category: Actions · Full reference →

ChipChip
  • For tags, filters and selected values (a multi-select, recipients of a message).
  • For read-only statuses use a Badge.
import pyzed as pz
from pyzed import ui
class Tags(pz.App):
def __init__(self):
self.tags = ["python", "rust", "iced"]
def view(self):
return pz.row([ui.chip(t, on_remove=lambda t=t: self.tags.remove(t)) for t in self.tags],
spacing=6, wrap=True)
Chip: StaticChip: Static
Static
Code
ui.chip("python")
Chip: on_press=Chip: on_press=
on_press=
Code
ui.chip("rust", on_press=on_filter)
Chip: selected=TrueChip: selected=True
selected=True
Code
ui.chip("python", on_press=on_filter, selected=True)
Chip: on_remove=Chip: on_remove=
on_remove=
Code
ui.chip("iced", on_remove=on_remove)
Chip: icon="tag"Chip: icon="tag"
icon="tag"
Code
ui.chip("design", icon="tag")
Chip: Icon and removeChip: Icon and remove
Icon and remove
Code
ui.chip("ada@example.com", icon="user", on_remove=on_remove)
Chip: Selected with iconChip: Selected with icon
Selected with icon
Code
ui.chip("favorites", icon="star", selected=True, on_press=on_filter)
Chip: tint="error"Chip: tint="error"
tint="error"
Code
ui.chip("Failing", on_press=on_press, selected=True, tint="error")
Chip: disabled=TrueChip: disabled=True
disabled=True
Code
ui.chip("Archived", on_press=on_press, on_remove=on_remove, disabled=True)

Chip has 2 events of its own, listed below. 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.

Event Handler gets When
on_press () Message or callable sent on press. None disables the control.
on_remove () Shows a ✕ that sends this when clicked.

Handler gets is what Pyzed passes to your callable: () means nothing. Any handler can also be a message (a value that is not callable), which goes to update().

The same events written three ways. Imperative: methods of the app change self. Declarative: the handlers produce messages and one update() decides. Functional: a pure function draws an immutable state and asks for changes with set_state(...). See Imperative, declarative and functional.

class Filters(pz.App):
def __init__(self):
self.tags = ["python", "rust", "iced"]
self.active = "python"
def view(self):
return pz.row([
ui.chip(t, selected=t == self.active,
on_press=lambda t=t: setattr(self, "active", t), # pick it
on_remove=lambda t=t: self.tags.remove(t)) # its ✕
for t in self.tags
], spacing=6, wrap=True)
chip(
content,
*,
on_press=None,
on_remove=None,
selected=False,
icon=None,
tint='accent',
disabled=False,
theme=None,
)

A compact tag, optionally clickable (filters) and with a button to remove it.

Property Default Description
content required Text.
selected False Marks it as selected.
icon None Name of a Lucide icon (pyzed icons lists them).
tint "accent" Color when selected (a theme token).
disabled False Greys it out and ignores presses.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_press, on_remove (events).

Full reference →