@molecule/app-progress-bar-angular
Feature · progress-bar · App (browser) · v1.1.3 · Apache-2.0
Angular labeled progress bar with card wrapper
npm install @molecule/app-progress-bar-angularHow it works
@molecule/app-progress-bar-angular is a ready-made progress-bar 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 { ProgressBar, ProgressCard } from '@molecule/app-progress-bar-angular'
@Component({
selector: 'app-dashboard',
standalone: true,
imports: [ProgressBar, ProgressCard],
template: `
<div mol-progress-bar [value]="65" label="Upload progress" valueLabel="65%"></div>
<div
mol-progress-card
[title]="'Storage used'"
[description]="'8.5 GB of 10 GB'"
[value]="85"
valueLabel="85%"
color="warning"
></div>
`,
})
export class Dashboard {}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular labeled progress bar and progress-card wrapper — the counterpart of
@molecule/app-progress-bar-react, with the same props and the same DOM.
Exports:
<ProgressBar>(div[mol-progress-bar]) — standalone bar with optional label + value display.<ProgressCard>(div[mol-progress-card]) — Card-wrapped progress display (title, icon, description, bar, optional extras slot).
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 { ProgressBar, ProgressCard } from '@molecule/app-progress-bar-angular'
@Component({
selector: 'app-dashboard',
standalone: true,
imports: [ProgressBar, ProgressCard],
template: `
<div mol-progress-bar [value]="65" label="Upload progress" valueLabel="65%"></div>
<div
mol-progress-card
[title]="'Storage used'"
[description]="'8.5 GB of 10 GB'"
[value]="85"
valueLabel="85%"
color="warning"
></div>
`,
})
export class Dashboard {}
Type
feature
Installation
npm install @molecule/app-progress-bar-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
ProgressBarProps
Props accepted by ProgressBar — the same props
@molecule/app-progress-bar-react accepts. Node props (label,
valueLabel) are typed unknown: pass a plain string as the input, or
project content as [slot=<name>] children of the host element.
interface ProgressBarProps {
/** Current numeric value. */
value: number
/** Maximum (defaults to 100). */
max?: number
/** Optional label rendered above the track — a string input, or `[slot=label]` content. */
label?: unknown
/** Optional value display on the right of the label row — a string input, or `[slot=valueLabel]` content. */
valueLabel?: unknown
/**
* Element id the track is named by (`aria-labelledby`). Wins over `label`
* and the default accessible name — `ProgressCard` points it at its title.
*/
labelledBy?: string
/** Element id the track is described by (`aria-describedby`). */
describedBy?: string
/** Size preset — maps to ClassMap `progressHeight`. */
size?: 'sm' | 'md' | 'lg'
/** Color variant — maps to ClassMap `progressColor`. */
color?: 'primary' | 'success' | 'warning' | 'error' | 'info'
/** Extra classes on the outer wrapper. */
className?: string
}
ProgressCardProps
Props accepted by ProgressCard — the same props
@molecule/app-progress-bar-react accepts. Node props (title,
description, icon, valueLabel, children) are typed unknown: pass a
plain string as the input, or project content as [slot=<name>] children of
the host element.
interface ProgressCardProps {
/** Card title — a string input, or `[slot=title]` projected content. */
title?: unknown
/** Optional supporting description below the title — a string input, or `[slot=description]` content. */
description?: unknown
/** Optional icon shown in the card header — `[slot=icon]` projected content (or a string input). */
icon?: unknown
/** Current value. */
value: number
/** Maximum (defaults to 100). */
max?: number
/** Value display on the right of the header — a string input, or `[slot=valueLabel]` content. */
valueLabel?: unknown
/** ProgressBar color. */
color?: 'primary' | 'success' | 'warning' | 'error' | 'info'
/** Extra classes on the Card wrapper. */
className?: string
/** Additional content rendered below the bar, projected as the element's default content. */
children?: unknown
}
Classes
ProgressBar
ProgressBar component.
Labeled progress bar with optional value display: a [label ... valueLabel]
header row above a track, with the track and fill styled by the ClassMap
progress tokens. The host IS the outer <div> (div[mol-progress-bar]),
matching React's root exactly. Node props (label, valueLabel) are
projected content ([slot=<name>]) or plain string inputs.
The track always carries an accessible name (aria-progressbar-name):
labelledBy when given, else the rendered label, else
t('progressBar.label', undefined, { defaultValue: 'Progress' }), read
through useTranslation() so it follows a locale switch.
This is the Angular counterpart of @molecule/app-progress-bar-react: the
same props (React names), the same ClassMap tokens, and the same DOM for the
same input.
@Component({
selector: 'div[mol-progress-bar]',
standalone: true,
hostDirectives: [MolPlacement],
inputs: [
'value',
'max',
'label',
'valueLabel',
'labelledBy',
'describedBy',
'size',
'color',
'className',
],
host: {
'[class]': 'classes()',
},
// prettier-ignore
template: `<div #headerEl [class]="headerClasses()"><span #labelEl [attr.id]="nameByLabel ? labelId : null" [class]="labelClasses()">@if (hasLabel) {{{ label }}}<ng-content select="[slot=label]" /></span><span #valueLabelEl [class]="valueLabelClasses()">@if (hasValueLabel) {{{ valueLabel }}}<ng-content select="[slot=valueLabel]" /></span></div><div [class]="trackClasses()" role="progressbar" [attr.aria-valuenow]="value" [attr.aria-valuemin]="0" [attr.aria-valuemax]="maxValue()" [attr.aria-labelledby]="trackLabelledBy" [attr.aria-label]="trackAriaLabel" [attr.aria-describedby]="describedBy"><div [class]="fillClasses()" [style]="fillStyleText()"></div></div>`,
})
export class ProgressBar {
/** Current numeric value. */
value!: number
/** Maximum (defaults to `100` at read time). */
max?: number
/** Optional label rendered above the track — a string input, or `[slot=label]` content. */
label?: ProgressBarProps['label']
/** Optional value display on the right of the label row — a string input, or `[slot=valueLabel]` content. */
valueLabel?: ProgressBarProps['valueLabel']
/** Element id the track is named by — wins over `label` and the default name. */
labelledBy?: string
/** Element id the track is described by (`aria-describedby`). */
describedBy?: string
/** Size preset — maps to ClassMap `progressHeight` (defaults to `'md'`). */
size?: 'sm' | 'md' | 'lg'
/** Color variant — maps to ClassMap `progressColor` (defaults to `'primary'`). */
color?: 'primary' | 'success' | 'warning' | 'error' | 'info'
/** Extra classes on the outer wrapper. */
className?: string
/** Per-instance counter backing `ProgressBar.labelId` (React numbers `useId()` ids). */
private static nextId = 0
/** The id the track's `aria-labelledby` points at when the rendered label names it. */
readonly labelId = `mol-progress-bar-name-${ProgressBar.nextId++}`
/** The i18n handle (locale-reactive), read in an injection context. */
private readonly i18n = useTranslation()
/** The header row (present while either optional region renders). */
@ViewChild('headerEl', { static: true }) private headerEl?: ElementRef<HTMLElement>
/** The optional label span (its projected nodes decide whether it shows). */
@ViewChild('labelEl', { static: true }) private labelEl?: ElementRef<HTMLSpanElement>
/** The optional value-label span (its projected nodes decide whether it shows). */
@ViewChild('valueLabelEl', { static: true }) private valueLabelEl?: ElementRef<HTMLSpanElement>
/** Whether a `[slot=label]` projection landed (placement decides). */
private readonly labelShown = signal(false)
/** Whether a `[slot=valueLabel]` projection landed (placement decides). */
private readonly valueLabelShown = signal(false)
/** Keeps the header row and its two optional regions on the page only while they render a text input or projected content, re-decided whenever either changes (a s… */
constructor() {
usePlacement((hasContent) => {
const labelEl = this.labelEl?.nativeElement
const valueLabelEl = this.valueLabelEl?.nativeElement
const showLabel = this.hasLabel || (labelEl ? hasContent(labelEl) : false)
const showValueLabel = this.hasValueLabel || (valueLabelEl ? hasContent(valueLabelEl) : false)
this.labelShown.set(showLabel)
this.valueLabelShown.set(showValueLabel)
setElementPresent(labelEl, showLabel)
setElementPresent(valueLabelEl, showValueLabel)
setElementPresent(this.headerEl?.nativeElement, showLabel || showValueLabel)
})
}
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/** Whether a text label input renders (React's `label && …`). */
get hasLabel(): boolean {
return this.label !== undefined && this.label !== null && !!this.label
}
/** Whether a text value-label input renders (React's `valueLabel && …`). */
get hasValueLabel(): boolean {
return this.valueLabel !== undefined && this.valueLabel !== null && !!this.valueLabel
}
/** Whether the label span renders: a truthy text input or a `[slot=label]` projection. */
get showLabel(): boolean {
return this.hasLabel || this.labelShown()
}
/** Whether the value-label span renders. */
get showValueLabel(): boolean {
return this.hasValueLabel || this.valueLabelShown()
}
/** Whether the header row renders at all (React's `(label || valueLabel)`). */
get showHeader(): boolean {
return this.showLabel || this.showValueLabel
}
/** Whether the rendered label is the track's name (React names the track with the `label` unless an explicit `labelledBy` wins). */
get nameByLabel(): boolean {
return this.labelledBy === undefined && this.showLabel
}
/** The track's `aria-labelledby`: the `labelledBy` input when given, else the rendered label's id, else `null` (React omits the attribute). */
get trackLabelledBy(): string | null {
return this.labelledBy ?? (this.nameByLabel ? this.labelId : null)
}
/** The track's `aria-label`: the `t('progressBar.label')` default when no `labelledBy` input and no rendered label names it, else `null` (React omits the attribut… */
get trackAriaLabel(): string | null {
return this.labelledBy === undefined && !this.showLabel
? this.i18n.t('progressBar.label', undefined, { defaultValue: 'Progress' })
: null
}
/** The maximum width (React's default parameter: a later-bound write of `undefined` must not erase the `100` default). */
maxValue(): number {
return this.max ?? 100
}
/**
* The size preset (React's `size = 'md'`).
* @returns The size.
*/
sizeValue(): 'sm' | 'md' | 'lg' {
return this.size ?? 'md'
}
/**
* The color variant (React's `color = 'primary'`).
* @returns The color.
*/
colorValue(): 'primary' | 'success' | 'warning' | 'error' | 'info' {
return this.color ?? 'primary'
}
/** The fill percentage React computes (`max === 0` renders empty). */
fillPercent(): number {
const max = this.maxValue()
return max === 0 ? 0 : Math.max(0, Math.min(100, (this.value / max) * 100))
}
/** The fill's inline style (React's `{ width: '<pct>%' }`). */
fillStyleText(): string | null {
return styleText({ width: `${this.fillPercent()}%` })
}
/** The host's class list (React's `cm.cn(cm.stack(2), className)`). */
classes(): string {
const cm = this.cm()
return cm.cn(cm.stack(2), this.className)
}
/** The header row's class list (React's `cm.flex({ justify: 'between', align: 'center' })`). */
headerClasses(): string {
return this.cm().flex({ justify: 'between', align: 'center' })
}
/**
* The label span's class list (React's `cm.cn(cm.textSize('sm'), cm.fontWeight('medium'))`).
* @returns The class string.
*/
labelClasses(): string {
const cm = this.cm()
return cm.cn(cm.textSize('sm'), cm.fontWeight('medium'))
}
/**
* The value-label span's class list (React's `cm.textSize('sm')`).
* @returns The class string.
*/
valueLabelClasses(): string {
return this.cm().textSize('sm')
}
/**
* The track's class list (React's `cm.cn(cm.progress(), cm.progressHeight(size))`).
* @returns The class string.
*/
trackClasses(): string {
const cm = this.cm()
return cm.cn(cm.progress(), cm.progressHeight(this.sizeValue()))
}
/**
* The fill's class list (React's `cm.cn(cm.progressBar(), cm.progressColor(color))`).
* @returns The class string.
*/
fillClasses(): string {
const cm = this.cm()
return cm.cn(cm.progressBar(), cm.progressColor(this.colorValue()))
}
}
(The 14 longest member comments are shortened to their first sentence to fit; the full declaration is in node_modules/@molecule/app-progress-bar-angular/dist/progress-bar.component.d.ts.)
ProgressCard
ProgressCard component.
<Card>-wrapped progress display with title, optional icon and description,
the progress bar itself, and an optional extras slot below. The host IS the
Card div (div[mol-progress-card]), matching React's root exactly — same
classes. Node props (title, description, icon, valueLabel,
children) are projected content ([slot=<name>], or the default
projection) or plain string inputs.
The bar is named by the title (aria-labelledby) and, when a description
renders, described by it (aria-describedby).
This is the Angular counterpart of @molecule/app-progress-bar-react: the
same props (React names), the same ClassMap tokens, and the same DOM for the
same input.
@Component({
selector: 'div[mol-progress-card]',
standalone: true,
hostDirectives: [MolPlacement],
imports: [ProgressBar],
inputs: ['title', 'description', 'icon', 'value', 'max', 'valueLabel', 'color', 'className'],
host: {
'[class]': 'classes()',
},
// prettier-ignore
template: `<div [class]="stackClasses()"><div [class]="headerClasses()"><div [class]="leftClasses()">@if (hasIcon) {{{ icon }}}<ng-content select="[slot=icon]"></ng-content><div><h3 [attr.id]="titleId" [class]="titleClasses()">@if (hasTitle) {{{ title }}}<ng-content select="[slot=title]"></ng-content></h3><p #descriptionEl [attr.id]="descriptionId" [class]="descriptionClasses()">@if (hasDescription) {{{ description }}}<ng-content select="[slot=description]"></ng-content></p></div></div><span #valueLabelEl [class]="valueLabelClasses()">@if (hasValueLabel) {{{ valueLabel }}}<ng-content select="[slot=valueLabel]"></ng-content></span></div><div mol-progress-bar [value]="value" [max]="maxValue()" [color]="colorValue()" [labelledBy]="titleId" [describedBy]="describedById ?? undefined"></div><ng-content></ng-content></div>`,
})
export class ProgressCard {
/** Card title — a string input, or `[slot=title]` projected content. */
title?: ProgressCardProps['title']
/** Optional supporting description below the title — a string input, or `[slot=description]` content. */
description?: ProgressCardProps['description']
/** Optional icon shown in the card header — `[slot=icon]` projected content (or a string input). */
icon?: ProgressCardProps['icon']
/** Current value. */
value!: number
/** Maximum (defaults to `100` at read time). */
max?: number
/** Value display on the right of the header — a string input, or `[slot=valueLabel]` content. */
valueLabel?: ProgressCardProps['valueLabel']
/** ProgressBar color (defaults to `'primary'`). */
color?: 'primary' | 'success' | 'warning' | 'error' | 'info'
/** Extra classes on the Card wrapper. */
className?: string
/** Per-instance counter backing the title/description ids (React numbers `useId()` ids). */
private static nextId = 0
/** The id the bar's `aria-labelledby` points at (on the title heading). */
readonly titleId = `mol-progress-card-title-${ProgressCard.nextId++}`
/** The id the bar's `aria-describedby` points at (on the description paragraph). */
readonly descriptionId = `mol-progress-card-description-${ProgressCard.nextId++}`
/** The optional description paragraph (its projected nodes decide whether it shows). */
@ViewChild('descriptionEl', { static: true })
private descriptionEl?: ElementRef<HTMLParagraphElement>
/** The optional value-label span (its projected nodes decide whether it shows). */
@ViewChild('valueLabelEl', { static: true }) private valueLabelEl?: ElementRef<HTMLSpanElement>
/** Whether a `[slot=description]` projection landed (placement decides). */
private readonly descriptionShown = signal(false)
/** Whether a `[slot=valueLabel]` projection landed (placement decides). */
private readonly valueLabelShown = signal(false)
/**
* Keeps the optional description and value-label regions on the page only
* while they render a text input or projected content, re-decided whenever
* either changes (a slot taken away and given back included).
*/
constructor() {
usePlacement((hasContent) => {
const description = this.descriptionEl?.nativeElement
const valueLabel = this.valueLabelEl?.nativeElement
const showDescription = this.hasDescription || (description ? hasContent(description) : false)
const showValueLabel = this.hasValueLabel || (valueLabel ? hasContent(valueLabel) : false)
this.descriptionShown.set(showDescription)
this.valueLabelShown.set(showValueLabel)
setElementPresent(description, showDescription)
setElementPresent(valueLabel, showValueLabel)
})
}
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* Whether a text icon input renders (a projected icon is not).
* @returns True when the icon renders as text.
*/
get hasIcon(): boolean {
return this.icon !== undefined && this.icon !== null && this.icon !== false && this.icon !== ''
}
/**
* Whether a text title input renders (a projected title is not).
* @returns True when the title renders as text.
*/
get hasTitle(): boolean {
return this.title !== undefined && this.title !== null
}
/**
* Whether a text description input is present (React's `description && …`).
* @returns True when the description renders as text.
*/
get hasDescription(): boolean {
return (
this.description !== undefined &&
this.description !== null &&
this.description !== false &&
this.description !== ''
)
}
/**
* Whether a text value-label input is present (React's `valueLabel && …`).
* @returns True when the value label renders as text.
*/
get hasValueLabel(): boolean {
return (
this.valueLabel !== undefined &&
this.valueLabel !== null &&
this.valueLabel !== false &&
this.valueLabel !== ''
)
}
/**
* Whether the description paragraph renders.
* @returns True when the description shows.
*/
get showDescription(): boolean {
return this.hasDescription || this.descriptionShown()
}
/**
* Whether the value-label span renders.
* @returns True when the value label shows.
*/
get showValueLabel(): boolean {
return this.hasValueLabel || this.valueLabelShown()
}
/**
* The bar's `aria-describedby`: the description paragraph's id while the
* paragraph renders (React passes it only when a description is present).
* @returns The described-by id, or `null` (React omits the attribute).
*/
get describedById(): string | null {
return this.showDescription ? this.descriptionId : null
}
/**
* The maximum (React's default parameter: a later-bound write of `undefined`
* must not erase the `100` default).
* @returns The maximum.
*/
maxValue(): number {
return this.max ?? 100
}
/**
* The color variant (React's `color = 'primary'`).
* @returns The color.
*/
colorValue(): 'primary' | 'success' | 'warning' | 'error' | 'info' {
return this.color ?? 'primary'
}
/**
* The host's class list (React's `<Card className>` classes).
* @returns The class string.
*/
classes(): string {
const cm = this.cm()
return cm.cn(cm.card({ variant: 'elevated' }), cm.cardPadding('md'), this.className)
}
/**
* The stack wrapper's class list (React's `cm.stack(3)`).
* @returns The class string.
*/
stackClasses(): string {
return this.cm().stack(3)
}
/**
* The header row's class list (React's `cm.flex({ justify: 'between', align: 'start', gap: 'sm' })`).
* @returns The class string.
*/
headerClasses(): string {
return this.cm().flex({ justify: 'between', align: 'start', gap: 'sm' })
}
/**
* The left group's class list (React's `cm.flex({ align: 'center', gap: 'sm' })`).
* @returns The class string.
*/
leftClasses(): string {
return this.cm().flex({ align: 'center', gap: 'sm' })
}
/**
* The title heading's class list (React's `cm.cn(cm.textSize('base'), cm.fontWeight('semibold'))`).
* @returns The class string.
*/
titleClasses(): string {
const cm = this.cm()
return cm.cn(cm.textSize('base'), cm.fontWeight('semibold'))
}
/**
* The description paragraph's class list (React's `cm.textSize('sm')`).
* @returns The class string.
*/
descriptionClasses(): string {
return this.cm().textSize('sm')
}
/**
* The value-label span's class list (React's `cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))`).
* @returns The class string.
*/
valueLabelClasses(): string {
const cm = this.cm()
return cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))
}
}
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
All visible text (label, valueLabel, title, description) is
pass-through — supply already-translated strings. The track's fallback
accessible name resolves through t('progressBar.label', undefined, { defaultValue: 'Progress' }) (read through useTranslation(), so it
follows a locale switch); a rendered label or a labelledBy id names it
instead. Requires a wired ClassMap bond: the track/fill styles come from the
progress* ClassMap tokens, so colors follow the active theme. Node props
are projected content ([slot=<name>]) or plain string inputs.
Translations
Translation strings are provided by @molecule/app-locales-progress-bar.