Skip to content

Component Tag

MeowLynxSea edited this page Jun 18, 2026 · 4 revisions

Tag

A selectable / closable chip. Distinct from Badge: Tag carries a click and an optional × button; Badge is purely visual.

use yororen_ui::headless::tag::tag;

tag("lang-rust", "rust", cx)
    .closable(true)
    .on_close({
        let entity = cx.entity();
        move |_, cx| entity.update(cx, |s, _| s.tags.retain(|t| t != "rust"));
    })
    .render(cx)

Props

Method Purpose
selected(v) Apply the selected visual state.
closable(v) Show the × button.
on_click(closure) Fn(&ClickEvent, &mut Window, &mut App) + 'static + Send + Sync.
on_close(closure) Fn(&mut Window, &mut App) + 'static + Send + Sync.
disabled(v) Disable both on_click and on_close.

Label is set at construction. .render(cx) returns Stateful<Div>.

See also: Badge, Button.

Clone this wiki locally