@molecule/app-status-badge-angular
Feature · status-badge · App (browser) · v1.1.2 · Apache-2.0
Angular status badge / pill with semantic kinds
npm install @molecule/app-status-badge-angularHow it works
@molecule/app-status-badge-angular is a ready-made status-badge feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { Component } from '@angular/core'
import { StatusBadge, StatusPill } from '@molecule/app-status-badge-angular'
@Component({
selector: 'app-row',
standalone: true,
imports: [StatusBadge, StatusPill],
template: `
<span mol-status-badge kind="success">Open</span>
<span mol-status-badge kind="warning" appearance="uppercase-pill">
<span slot="icon" aria-hidden="true">!</span>
Pending
</span>
<span mol-status-pill kind="error">Overdue</span>
`,
})
export class Row {}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular status-badge and status-pill components.
Both components map a small StatusKind union (success/warning/
error/info/neutral) to ClassMap-driven styling so apps can
restyle by swapping the ClassMap bond rather than rewriting
components.
<span mol-status-badge kind="…">children</span> — the contract is
kind + projected children (there are NO label/color props).
appearance='ui' (default) carries the framework <Badge>'s ClassMap
styling and works with any ClassMap bond.
<span mol-status-pill kind="…">children</span> adds a small colored
status dot before the label.
This is the Angular counterpart of @molecule/app-status-badge-react: the
same props (React names) and the same DOM for the same input. Node props are
projected content: the icon is [slot=icon], everything else is the default
projection.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { Component } from '@angular/core'
import { StatusBadge, StatusPill } from '@molecule/app-status-badge-angular'
@Component({
selector: 'app-row',
standalone: true,
imports: [StatusBadge, StatusPill],
template: `
<span mol-status-badge kind="success">Open</span>
<span mol-status-badge kind="warning" appearance="uppercase-pill">
<span slot="icon" aria-hidden="true">!</span>
Pending
</span>
<span mol-status-pill kind="error">Overdue</span>
`,
})
export class Row {}
Type
feature
Installation
npm install @molecule/app-status-badge-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
StatusBadgeProps
Props accepted by StatusBadge — the same props
@molecule/app-status-badge-react accepts. Node props (children, icon)
are projected content in Angular (an input cannot carry a node), so they are
typed unknown: pass them in the host template, not as values. icon is
selected by [slot=icon]; everything else is the default projection.
interface StatusBadgeProps {
/** Semantic kind — maps to ClassMap badge color variants. */
kind?: StatusKind
/** Badge label, projected as the element's default content. */
children?: unknown
/** Optional leading icon, projected as `[slot=icon]` content. */
icon?: unknown
/**
* Visual appearance variant.
* - `'ui'` (default) — the ClassMap badge styling, honoring the active
* ClassMap bond and working with any theme.
* - `'uppercase-pill'` — a compact uppercase pill that colors itself with
* the SAME ClassMap `badge` tokens, then layers `cm.uppercase` +
* `cm.trackingWide` for the uppercase treatment.
*/
appearance?: 'ui' | 'uppercase-pill'
/** Extra classes passed through to the rendered element. */
className?: string
}
StatusPillProps
Props accepted by StatusPill — the same props
@molecule/app-status-badge-react accepts. children is projected content.
interface StatusPillProps {
/** Semantic kind. */
kind?: StatusKind
/** Pill label, projected as the element's default content. */
children?: unknown
/** Render a leading dot indicator. Defaults to true. */
dot?: boolean
/** Extra classes. */
className?: string
}
Types
StatusKind
Semantic status kind used to select badge color variants.
type StatusKind = 'success' | 'warning' | 'error' | 'info' | 'neutral'
Classes
StatusBadge
Semantic status badge — maps status kinds to ClassMap color variants.
The host IS the span React renders (span[mol-status-badge]), so both
appearances stay a single <span>: 'ui' (default) carries the ClassMap
badge classes of the framework <Badge>, and 'uppercase-pill' the same
per-kind colors plus cm.uppercase + cm.trackingWide. The optional icon
is projected as [slot=icon] content inside React's
<span class="mr-1">…</span> wrapper; the wrapper is detached when the
projection carries no nodes, exactly as React renders nothing for an absent
icon.
@Component({
selector: 'span[mol-status-badge]',
standalone: true,
hostDirectives: [MolPlacement],
inputs: ['kind', 'appearance', 'className'],
host: {
'[class]': 'classes()',
},
template: `<span [class]="iconClass()" #iconSlot
><ng-content select="[slot=icon]"></ng-content
></span>
<ng-content></ng-content>`,
})
export class StatusBadge {
/** Semantic kind — maps to ClassMap badge color variants (defaults to `'neutral'`). */
kind?: StatusKind
/** Visual appearance variant (defaults to `'ui'`). */
appearance?: 'ui' | 'uppercase-pill'
/** Extra classes passed through to the rendered element. */
className?: string
/** The icon wrapper (always in the template; detached when unused). */
@ViewChild('iconSlot') iconSlot?: ElementRef<HTMLSpanElement>
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* The semantic kind (React's `kind = 'neutral'` default parameter).
* @returns The kind.
*/
kindValue(): StatusKind {
return this.kind ?? 'neutral'
}
/**
* Computes the root span's class list, per appearance: React's `<Badge>`
* classes for `'ui'`, the uppercase pill's classes for `'uppercase-pill'`.
* @returns The class string.
*/
classes(): string {
const cm = this.cm()
const color = KIND_TO_COLOR[this.kindValue()]
if ((this.appearance ?? 'ui') === 'uppercase-pill') {
return cm.cn(cm.badge({ variant: color }), cm.uppercase, cm.trackingWide, this.className)
}
return cm.cn(cm.badge({ variant: color }), this.className)
}
/**
* Computes the icon wrapper's class list (`cm.sp('mr', 1)`).
* @returns The class string.
*/
iconClass(): string {
return this.cm().sp('mr', 1)
}
/**
* Renders the icon wrapper only while its slot has content — React renders
* no wrapper for an absent icon. The `<ng-content>` capture point stays in
* the template, so the wrapper leaves the page instead, and comes back when
* a consumer projects an icon later.
*/
constructor() {
usePlacement((hasContent) => {
const icon = this.iconSlot?.nativeElement
setElementPresent(icon, icon ? hasContent(icon) : false)
})
}
}
StatusPill
Rounded status pill with an optional leading colored dot.
The host IS the span React renders (span[mol-status-pill]). The pill has NO
background surface of its own — only the dot carries color — so add a
surface via className if you need a filled pill. The label is the default
projection; the dot is a boolean prop, exactly as in React.
@Component({
selector: 'span[mol-status-pill]',
standalone: true,
inputs: ['kind', 'dot', 'className'],
host: {
'[class]': 'classes()',
},
template: `@if (showDot()) {
<span [class]="dotClass()" aria-hidden="true"></span>
}
<ng-content></ng-content>`,
})
export class StatusPill {
/** Semantic kind (defaults to `'neutral'`). */
kind?: StatusKind
/** Whether the leading dot renders (defaults to true). */
dot?: boolean
/** Extra classes. */
className?: string
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* The semantic kind (React's `kind = 'neutral'` default parameter).
* @returns The kind.
*/
kindValue(): StatusKind {
return this.kind ?? 'neutral'
}
/**
* Whether the leading dot renders (React's `dot = true` default parameter).
* @returns True while the dot renders.
*/
showDot(): boolean {
return this.dot ?? true
}
/**
* Computes the root span's class list.
* @returns The class string.
*/
classes(): string {
return this.cm().cn(
this.cm().flex({ align: 'center', gap: 'xs' }),
this.cm().sp('px', 3),
this.cm().sp('py', 1),
this.cm().roundedFull,
this.cm().textSize('xs'),
this.cm().fontWeight('medium'),
this.className,
)
}
/**
* Computes the dot span's class list (`cm.w(2)` + `cm.h(2)` + `cm.roundedFull`
* + the kind's color token).
* @returns The class string.
*/
dotClass(): string {
const cm = this.cm()
return cm.cn(cm.w(2), cm.h(2), cm.roundedFull, DOT_COLOR[this.kindValue()])
}
}
Injection Notes
Requirements
Peer dependencies:
@angular/common^22.0.0@angular/core^22.0.0@angular/platform-browser^22.0.0@molecule/app-angular^3.13.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-angular^1.1.0
Runtime Dependencies
-
@angular/common -
@angular/core -
@angular/platform-browser -
@molecule/app-angular -
@molecule/app-ui -
@molecule/app-ui-angular -
Requires a wired ClassMap bond (e.g.
@molecule/app-ui-tailwind) —getClassMap()throws before bonding. -
The host element IS the badge span (
span[mol-status-badge]/span[mol-status-pill]), so the rendered DOM is exactly React's. -
The
'uppercase-pill'variant colors through the same ClassMapbadgetokens and layerscm.uppercase+cm.trackingWide, so every kind is visibly colored in every theme. -
<StatusPill>has no background surface of its own — only the dot is colored; add a surface viaclassNameif you need a filled pill. Itsneutraldot usesbg-outline, which also needs a themeoutlinecolor token to be visible. -
Labels are the projected children — pass already-translated strings (
t('...')); the components render no text of their own.