Reference

Chip

A compact label — a filter, a tag, a person — that can carry an icon, be pressed (selected:, with on click), and be removed (.removable, with on remove). Tag is the one that does none of it.

Chip(_ label: String, icon: String, selected: Bool, removable: Bool)

Since 6.2.0

icon

selected

removable

Rust TypeScript Go Python

4 languages, open only: false

Example

wf

state langs = ["Rust", "TypeScript", "Go", "Python"] state openOnly = false Stack(gap: .sm, align: .start) { Row(gap: .xs) { for l in langs by l { Chip(l, icon: "code").removable { on remove { langs = langs.filter(x => x != l) } } } } Chip("Open issues only", selected: openOnly) { on click { openOnly = !openOnly } } Text("{langs.length} languages, open only: {openOnly}").muted }

A filter row of toggles

wf

state picked: [String] = ["web"] Row(gap: .xs) { for f in ["web", "api", "worker"] by f { Chip(f, selected: picked.includes(f)) { on click { picked = if picked.includes(f) { picked.filter(x => x != f) } else { picked.concat([f]) } } } } }

Props

Props of Chip
PropTypeUnsetMeaning

label

String (positional)

—

Its words

icon:

String

none

An icon's name, drawn before the words

selected:

Bool

none: not a button unless it has on click

Pressed (aria-pressed): a filter that is on, filled in the primary colour. Given at all, true or false, it makes the chip a toggle button. Written as a flag, .selected, or selected: true.

removable:

Bool

false

A button after the words, named Remove {label}, that fires on remove. Written as a flag, .removable, or removable: true.

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.selected

.removable

Events

Events of Chip
EventSendsMeaning
on remove—

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Parts

The parts of Chip are written under its name, inside it. Each is described here, with what it takes.

Chip.Action

What pressing a chip presses: its icon and words, a toggle button when it can be selected:.

Chip.Action(_ text: String) { … }
Props of Chip.Action
PropTypeUnsetMeaning

text

String (positional)

none

Its words

Chip.Label

Its icon and words, when pressing it does nothing.

Chip.Label(_ text: String) { … }
Props of Chip.Label
PropTypeUnsetMeaning

text

String (positional)

none

Its words

Chip.Remove

Its remove button.

Chip.Remove { … }

Renders with the class wf-chip, stable across releases, so a stylesheet may target it.