CornerBadge

CornerBadge

HkCornerBadge is the anchored mark: a dot, a notification count with an N+ cap, or a short custom label placed on a corner of — or beside — whatever sits in the default slot. It is the one component every hand-rolled "badge on a trigger" converged on, and it is decorative by default: it visualises state the anchor already exposes, and only its label prop makes it announce anything.

  • The slot is the anchor, never the label text. Overloading it made every anchored child's own text leak into the badge, which is the bug this component retires.
  • For a standalone status pill that is part of the content flow, use Badge; for a dismissible entity chip, use Tag.

Import

tsx
1
import { HkCornerBadge } from "@celestia-island/hikari";
rust
1
2
use hikari_components::theme::CornerBadge;  // not in the crate root, see the note below
use hikari_components::prelude::*;          // rsx!, VNode

The Rust mirror lives under hikari_components::theme — this page's component sits in the crate's theme module, not at the crate root, so use hikari_components::*; does not bring CornerBadge into scope and the name has to be imported from its module. The CornerBadgeVariant and CornerBadgePlacement enums travel with it from the same module, and each example below repeats that import because an example is compiled on its own.

An rsx! component block only accepts an identifier, not a path: theme::CornerBadge { … } does not parse. The import has to be a block-level use before the rsx! — the same shape the examples use.

The Rust form is a plain function, CornerBadge(CornerBadgeProps { … }). Inside rsx! every prop may be omitted, and the component's children are the anchor.

Counts, caps and custom text

count renders the number. 0 hides the mark unless showZero — notification semantics — and a count past max renders {max}+; a count that equals max renders the plain number. Without a count, text is the label; an empty string hides the mark. The count form wins over text.

The mark itself is aria-hidden unless label is given, which is why the count is a visual claim here: it announces nothing until the host names it.

InboxUnread99+ReleaseZero

Dots

dot renders the bare dot form — the traffic-light marker — with no text at all. It shows whenever dot is set, even when the text resolution hid a count, and the mark then keeps the dot's own geometry.

OnlineDegradedIdle

Placement and offset

The six placements fall into two families. top-right, top-left, bottom-right (the default) and bottom-left overlay the anchor: the mark centres on the corner, half of it straddling the edge. right and left put the mark in the wrapper's flow beside the anchor, vertically centred, so the anchor's own box and text are never covered — the button-group and tab-trigger default.

offset is a number of pixels of extra clearance. On a corner it pushes the mark off the corner; on a side it adds to the shared gap. 0 — the default — means "sit on the corner", and it writes no custom property at all.

SessionsSessionsFiltersRange

API

Vue

Props

NameTypeDefaultRequired
variantString as PropType<CornerBadgeVariant>"primary"—
dotBooleanfalse—
countNumberundefined—
maxNumberundefined—
showZeroBooleanfalse—
textStringundefined—
placementString as PropType<CornerBadgePlacement>"bottom-right"—
offsetNumber0—
labelStringundefined—

Rust

Props — CornerBadge

PropTypeDefaultDescription
variantCornerBadgeVariantCornerBadgeVariant::Primary—
dotboolfalseBare dot form (the green/red/traffic light) — renders no text.
countOption<i64>NoneCount form: the number, or {max}+ past max, hidden at 0 unless show_zero.
maxOption<i64>None—
show_zeroboolfalse—
textOption<String>NoneCustom label text (the pill form).
placementCornerBadgePlacementCornerBadgePlacement::BottomRightWhere the mark hangs (Vue: placement; the three corner families overlay, Right/Left sit beside the anchor).
offseti640Extra clearance in px.
labelOption<String>NoneAccessible name; without it the mark is decorative (aria-hidden).
childrenElement(empty)The anchored child (Vue: the default slot).

Accessibility

  • Without label the mark is aria-hidden="true" decoration: it is skipped entirely, which is right when the anchor already says the same thing. Pass label when the count is announced nowhere else — the mark then becomes role="img" with that aria-label, the only path a count has to a screen reader.
  • The mark sets pointer-events: none and is not focusable, so it never steals a click or a Tab stop from the anchor.
  • A side placement (right / left) reads in document order after the anchor; the stylesheet moves it ahead of the anchor on left without changing the DOM, so keep the label meaningful on its own.
  • The label should read as a complete phrase — "128 unread messages" rather than "128", which announces as a bare number with no subject.

Related components

  • Badge — the standalone tone-coded label, for content flow rather than an anchor's corner.
  • Tag — the dismissible entity chip.
  • HkAvatar — the round identity chip that usually carries this mark.