Badge
HkBadge is the small tone-coded label: a pill (or a square, or a bare dot) that marks a piece of content with a state — a count, a version, a "beta", a live indicator — without taking a click. Its colour model is variable-driven: a variant sets the text, background and border channels coherently, and color / bgColor / borderColor override any single channel.
- A removable chip whose × runs the remove — a token, a filter, a selection — is a Tag.
- A count or a dot pinned to a corner of another element is HkCornerBadge.
- An identity chip that carries a person's picture or initial is HkAvatar.
Import
import { HkBadge } from "@celestia-island/hikari";
use hikari_components::*; use hikari_components::prelude::*;
The Rust form is a plain function, Badge(BadgeProps { … }). Inside rsx! every prop may be omitted and the component's children are the badge text — Badge { "Beta" } renders the same markup as <HkBadge>Beta</HkBadge>.
Variants
Seven tones: default (the plain neutral pill), primary, success, error, warning, info and muted. Each one sets all three colour channels at once, and each rides the theme palette, so a themed host recolours them together.
DefaultPrimarySuccessWarningErrorInfoMuted
DefaultPrimarySuccessWarningErrorInfoMuted
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" };
export default () => (
<div style={row}>
<HkBadge>Default</HkBadge>
<HkBadge variant="primary">Primary</HkBadge>
<HkBadge variant="success">Success</HkBadge>
<HkBadge variant="warning">Warning</HkBadge>
<HkBadge variant="error">Error</HkBadge>
<HkBadge variant="info">Info</HkBadge>
<HkBadge variant="muted">Muted</HkBadge>
</div>
);
rsx! {
div { style: "display:flex;gap:8px;align-items:center;flex-wrap:wrap",
Badge { "Default" }
Badge { variant: BadgeVariant::Primary, "Primary" }
Badge { variant: BadgeVariant::Success, "Success" }
Badge { variant: BadgeVariant::Warning, "Warning" }
Badge { variant: BadgeVariant::Error, "Error" }
Badge { variant: BadgeVariant::Info, "Info" }
Badge { variant: BadgeVariant::Muted, "Muted" }
}
}
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" };
export default () => (
<div style={row}>
<HkBadge>Default</HkBadge>
<HkBadge variant="primary">Primary</HkBadge>
<HkBadge variant="success">Success</HkBadge>
<HkBadge variant="warning">Warning</HkBadge>
<HkBadge variant="error">Error</HkBadge>
<HkBadge variant="info">Info</HkBadge>
<HkBadge variant="muted">Muted</HkBadge>
</div>
);rsx! {
div { style: "display:flex;gap:8px;align-items:center;flex-wrap:wrap",
Badge { "Default" }
Badge { variant: BadgeVariant::Primary, "Primary" }
Badge { variant: BadgeVariant::Success, "Success" }
Badge { variant: BadgeVariant::Warning, "Warning" }
Badge { variant: BadgeVariant::Error, "Error" }
Badge { variant: BadgeVariant::Info, "Info" }
Badge { variant: BadgeVariant::Muted, "Muted" }
}
}Size, shape and typography
size has two steps, sm and md (the default), carried by data-size. pill defaults to true; pill={false} gives the square-cornered chip. mono switches the label to the monospace family and uppercase upper-cases it with a little extra tracking — useful for a version tag or a code.
SmallMediumSquarev0.55.530Beta
SmallMediumSquarev0.55.530Beta
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" };
export default () => (
<div style={row}>
<HkBadge size="sm">Small</HkBadge>
<HkBadge>Medium</HkBadge>
<HkBadge pill={false}>Square</HkBadge>
<HkBadge mono>v0.55.530</HkBadge>
<HkBadge uppercase variant="info">Beta</HkBadge>
</div>
);
rsx! {
div { style: "display:flex;gap:8px;align-items:center;flex-wrap:wrap",
Badge { size: BadgeSize::Sm, "Small" }
Badge { "Medium" }
Badge { pill: false, "Square" }
Badge { mono: true, "v0.55.530" }
Badge { uppercase: true, variant: BadgeVariant::Info, "Beta" }
}
}
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" };
export default () => (
<div style={row}>
<HkBadge size="sm">Small</HkBadge>
<HkBadge>Medium</HkBadge>
<HkBadge pill={false}>Square</HkBadge>
<HkBadge mono>v0.55.530</HkBadge>
<HkBadge uppercase variant="info">Beta</HkBadge>
</div>
);rsx! {
div { style: "display:flex;gap:8px;align-items:center;flex-wrap:wrap",
Badge { size: BadgeSize::Sm, "Small" }
Badge { "Medium" }
Badge { pill: false, "Square" }
Badge { mono: true, "v0.55.530" }
Badge { uppercase: true, variant: BadgeVariant::Info, "Beta" }
}
}Dot and colour overrides
dot puts a small round marker before the text, and with no content at all the badge collapses into the dot alone — the badge drops its padding, border and background so that what remains is the indicator, not a dot inside an empty pill. In the Vue form pulse animates that dot (a live / in-flight state); it only takes effect together with dot, and a prefers-reduced-motion host gets the still dot.
The three colour props write the --hk-badge-text / --hk-badge-bg / --hk-badge-border custom properties, so they override exactly one channel of the variant and leave the other two alone.
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" };
export default () => (
<div style={row}>
<HkBadge variant="success" dot>Online</HkBadge>
<HkBadge variant="error" dot pulse>Live</HkBadge>
<HkBadge variant="success" dot />
<HkBadge color="#7c3aed" bgColor="#f3e8ff" borderColor="#d8b4fe">Custom ink</HkBadge>
</div>
);
rsx! {
div { style: "display:flex;gap:8px;align-items:center;flex-wrap:wrap",
Badge { variant: BadgeVariant::Success, dot: true, "Online" }
Badge { variant: BadgeVariant::Error, dot: true, "Live" }
Badge { variant: BadgeVariant::Success, dot: true }
Badge {
color: Some("#7c3aed".to_string()),
bg_color: Some("#f3e8ff".to_string()),
border_color: Some("#d8b4fe".to_string()),
"Custom ink"
}
}
}
import { HkBadge } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" };
export default () => (
<div style={row}>
<HkBadge variant="success" dot>Online</HkBadge>
<HkBadge variant="error" dot pulse>Live</HkBadge>
<HkBadge variant="success" dot />
<HkBadge color="#7c3aed" bgColor="#f3e8ff" borderColor="#d8b4fe">Custom ink</HkBadge>
</div>
);rsx! {
div { style: "display:flex;gap:8px;align-items:center;flex-wrap:wrap",
Badge { variant: BadgeVariant::Success, dot: true, "Online" }
Badge { variant: BadgeVariant::Error, dot: true, "Live" }
Badge { variant: BadgeVariant::Success, dot: true }
Badge {
color: Some("#7c3aed".to_string()),
bg_color: Some("#f3e8ff".to_string()),
border_color: Some("#d8b4fe".to_string()),
"Custom ink"
}
}
}
API
Vue
Props
Rust
Props — Badge
Accessibility
- The badge is a <span>: it carries no role, is not focusable and takes no clicks, so it never enters the tab order.
- The text is the accessible content — a variant colour never is. A badge that only says "Success" through its green fill is announced as the word "Success" and nothing more, so keep the meaning in the text.
- A dot with no text renders an empty marker, which is decorative; it announces nothing, and that is deliberate. If the dot is the only carrier of the state, put the state in the surrounding text.
- uppercase is a visual transform only: the text node keeps its original case for assistive technology and for copy-paste.
Related components
- Tag — the removable chip, with an optional close button.
- HkCornerBadge — a dot or a count anchored to another element's corner.
- HkAvatar — the round identity chip.