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
import { HkCornerBadge } from "@celestia-island/hikari";
use hikari_components::theme::CornerBadge; use hikari_components::prelude::*;
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.
Inbox3Unread99+ReleasebetaZero
Inbox3Unread99+ReleasebetaZero
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { HkCornerBadge } from "@celestia-island/hikari";
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "32px", alignItems: "center" };
export default () => (
<div style={row}>
<HkCornerBadge count={3}>
<HkBadge variant="primary">Inbox</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={128} max={99} label="128 unread messages">
<HkBadge variant="primary">Unread</HkBadge>
</HkCornerBadge>
<HkCornerBadge text="beta" variant="info">
<HkBadge>Release</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={0}>
<HkBadge>Zero</HkBadge>
</HkCornerBadge>
</div>
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use hikari_components::theme::{CornerBadge, CornerBadgePlacement, CornerBadgeVariant, CornerBadgeProps};
rsx! {
div { style: "display:flex;gap:32px;align-items:center",
CornerBadge { count: Some(3),
Badge { variant: BadgeVariant::Primary, "Inbox" }
}
CornerBadge { count: Some(128), max: Some(99),
Badge { variant: BadgeVariant::Primary, "Unread" }
}
CornerBadge { text: Some("beta".to_string()), variant: CornerBadgeVariant::Info,
Badge { "Release" }
}
CornerBadge { count: Some(0),
Badge { "Zero" }
}
}
}
import { HkCornerBadge } from "@celestia-island/hikari";
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "32px", alignItems: "center" };
export default () => (
<div style={row}>
<HkCornerBadge count={3}>
<HkBadge variant="primary">Inbox</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={128} max={99} label="128 unread messages">
<HkBadge variant="primary">Unread</HkBadge>
</HkCornerBadge>
<HkCornerBadge text="beta" variant="info">
<HkBadge>Release</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={0}>
<HkBadge>Zero</HkBadge>
</HkCornerBadge>
</div>
);use hikari_components::theme::{CornerBadge, CornerBadgePlacement, CornerBadgeVariant, CornerBadgeProps};
rsx! {
div { style: "display:flex;gap:32px;align-items:center",
CornerBadge { count: Some(3),
Badge { variant: BadgeVariant::Primary, "Inbox" }
}
CornerBadge { count: Some(128), max: Some(99),
Badge { variant: BadgeVariant::Primary, "Unread" }
}
CornerBadge { text: Some("beta".to_string()), variant: CornerBadgeVariant::Info,
Badge { "Release" }
}
CornerBadge { count: Some(0),
Badge { "Zero" }
}
}
}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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { HkCornerBadge } from "@celestia-island/hikari";
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "32px", alignItems: "center" };
export default () => (
<div style={row}>
<HkCornerBadge dot variant="success">
<HkBadge>Online</HkBadge>
</HkCornerBadge>
<HkCornerBadge dot variant="error" label="Degraded">
<HkBadge>Degraded</HkBadge>
</HkCornerBadge>
<HkCornerBadge dot>
<HkBadge>Idle</HkBadge>
</HkCornerBadge>
</div>
);
use hikari_components::theme::{CornerBadge, CornerBadgePlacement, CornerBadgeVariant, CornerBadgeProps};
rsx! {
div { style: "display:flex;gap:32px;align-items:center",
CornerBadge { dot: true, variant: CornerBadgeVariant::Success,
Badge { "Online" }
}
CornerBadge { dot: true, variant: CornerBadgeVariant::Error, label: Some("Degraded".to_string()),
Badge { "Degraded" }
}
CornerBadge { dot: true,
Badge { "Idle" }
}
}
}
import { HkCornerBadge } from "@celestia-island/hikari";
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "32px", alignItems: "center" };
export default () => (
<div style={row}>
<HkCornerBadge dot variant="success">
<HkBadge>Online</HkBadge>
</HkCornerBadge>
<HkCornerBadge dot variant="error" label="Degraded">
<HkBadge>Degraded</HkBadge>
</HkCornerBadge>
<HkCornerBadge dot>
<HkBadge>Idle</HkBadge>
</HkCornerBadge>
</div>
);use hikari_components::theme::{CornerBadge, CornerBadgePlacement, CornerBadgeVariant, CornerBadgeProps};
rsx! {
div { style: "display:flex;gap:32px;align-items:center",
CornerBadge { dot: true, variant: CornerBadgeVariant::Success,
Badge { "Online" }
}
CornerBadge { dot: true, variant: CornerBadgeVariant::Error, label: Some("Degraded".to_string()),
Badge { "Degraded" }
}
CornerBadge { dot: true,
Badge { "Idle" }
}
}
}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.
Sessions2Sessions2Filters2Range5h
Sessions2Sessions2Filters2Range5h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { HkCornerBadge } from "@celestia-island/hikari";
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "32px", alignItems: "center" };
export default () => (
<div style={row}>
<HkCornerBadge count={2} placement="top-right">
<HkBadge>Sessions</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={2} placement="bottom-left" offset={4}>
<HkBadge>Sessions</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={2} placement="right">
<HkBadge>Filters</HkBadge>
</HkCornerBadge>
<HkCornerBadge text="5h" placement="left">
<HkBadge>Range</HkBadge>
</HkCornerBadge>
</div>
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use hikari_components::theme::{CornerBadge, CornerBadgePlacement, CornerBadgeVariant, CornerBadgeProps};
rsx! {
div { style: "display:flex;gap:32px;align-items:center",
CornerBadge { count: Some(2), placement: CornerBadgePlacement::TopRight,
Badge { "Sessions" }
}
CornerBadge { count: Some(2), placement: CornerBadgePlacement::BottomLeft, offset: 4,
Badge { "Sessions" }
}
CornerBadge { count: Some(2), placement: CornerBadgePlacement::Right,
Badge { "Filters" }
}
CornerBadge { text: Some("5h".to_string()), placement: CornerBadgePlacement::Left,
Badge { "Range" }
}
}
}
import { HkCornerBadge } from "@celestia-island/hikari";
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "32px", alignItems: "center" };
export default () => (
<div style={row}>
<HkCornerBadge count={2} placement="top-right">
<HkBadge>Sessions</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={2} placement="bottom-left" offset={4}>
<HkBadge>Sessions</HkBadge>
</HkCornerBadge>
<HkCornerBadge count={2} placement="right">
<HkBadge>Filters</HkBadge>
</HkCornerBadge>
<HkCornerBadge text="5h" placement="left">
<HkBadge>Range</HkBadge>
</HkCornerBadge>
</div>
);use hikari_components::theme::{CornerBadge, CornerBadgePlacement, CornerBadgeVariant, CornerBadgeProps};
rsx! {
div { style: "display:flex;gap:32px;align-items:center",
CornerBadge { count: Some(2), placement: CornerBadgePlacement::TopRight,
Badge { "Sessions" }
}
CornerBadge { count: Some(2), placement: CornerBadgePlacement::BottomLeft, offset: 4,
Badge { "Sessions" }
}
CornerBadge { count: Some(2), placement: CornerBadgePlacement::Right,
Badge { "Filters" }
}
CornerBadge { text: Some("5h".to_string()), placement: CornerBadgePlacement::Left,
Badge { "Range" }
}
}
}
API
Vue
Props
Rust
Props — CornerBadge
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.