Tag (legacy)

Tag (legacy)

Tag is a legacy migration surface: the Rust crate's original chip, a <span> that pulls its classes from the palette's TagClass utilities and renders a bare <button> with a 12px close glyph when closable is set. It keeps existing Rust pages building; new code should prefer the Vue chip, HkTag.

  • The two are not mirrors of each other, despite the shared name. HkTag is a Vue-only component with its own stylesheet and a standard 16px icon button for its ×; Tag is this Rust component with hi-*-derived classes and a bespoke close button. The same name in the two languages means two different components.
  • Reach for it while migrating a Rust page that already renders this shape, and switch to the Vue chip's grammar when that page grows a Vue face.
  • A static label that is never dismissed is a Badge — the same tone family, with no close affordance.

Import

rust
1
2
use hikari_components::*;          // Tag, TagVariant
use hikari_components::prelude::*; // rsx!, VNode, EventHandler, MouseEvent, Icon, MdiIcon

The Rust form is a plain function, Tag(TagProps { … }). Inside rsx! the tone, the close flag, the class and the style all have defaults, and the examples below set the tone explicitly on every chip — the component's own default is TagVariant::Default.

Variants

Six tones: Default, Primary, Success, Warning, Danger and Info, mapped onto the palette's TagClass variants. The class list also brings the layout utilities — inline-flex, centered, a small gap — so the chip is a one-element composition and the host does not have to add classes.

Rust
DefaultPrimarySuccessWarningDangerInfo

A leading glyph and host classes

The chip's content is the default slot, so a glyph is just another child — the crate's own Icon at 12px sits before the text. class is appended after the component's own classes, and style lands on the same <span>; both are the escape hatches for a host that needs a one-off tint or spacing without a new component.

Rust
Starred
Pill

Closable

closable appends a <button class="hk-tag-close"> holding the crate's MdiIcon::Close glyph at 12px. The button has no text and no accessible name, and Tag offers no prop to give it one — the close it renders is a bare glyph button. A press calls on_close; the chip does not remove itself, so the host owns the list.

The handler is cloned before it moves into the closure, because the closure is Fn and the field is borrowed inside it — a snapshot cannot press the button, so the sample only shows the wiring.

Rust
project-atlasstatic

API

Rust

Props — Tag

PropTypeDefaultDescription
variantTagVariantTagVariant::Default—
closableboolfalse—
on_closeOption<EventHandler<MouseEvent>>None—
classString""—
styleString""—
childrenElement(empty)—

Notes

  • The close glyph is drawn by the crate's Icon and is not marked aria-hidden; the button it sits in carries no name either. Treat the × as pointer-only in practice, and give the surrounding row a keyboard path to the same action.
  • The chip's classes come from the palette's utility builder rather than from a component stylesheet, so a theme that overrides .hk-tag* rules may not reach it the way it reaches the Vue chip.
  • style is written to the <span> verbatim and wins over the class-derived rules only where inline styles naturally do — a host that needs to retint the chip writes the colour properties, not a whole rule.
  • The Vue chip HkTag is the preferred spelling for new surfaces: it ships the standard icon-button ×, a closeLabel, and the hk-tag-<size> step that this component does not have.

Accessibility

  • The chip is a <span> and is not focusable; only the close button is reachable, and it is a real <button>, so Enter and Space activate it.
  • The close button has no accessible name. It is announced as an unnamed button, so a screen-reader user cannot tell which chip it belongs to; if the removal matters, surface it outside the chip.
  • The tone is visual only — the text carries the meaning.

Related components

  • HkTag — the Vue chip with the same name; the preferred spelling, and not a mirror of this component.
  • Badge — the static tone-coded label.
  • HkCornerBadge — a mark anchored to another element's corner.