@molecule/app-checklist-angular
Feature · checklist · App (browser) · v1.1.2 · Apache-2.0
Onboarding checklist with checkable items + progress bar
npm install @molecule/app-checklist-angularHow it works
@molecule/app-checklist-angular is a ready-made checklist 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, signal } from '@angular/core'
import { Checklist, type ChecklistItem } from '@molecule/app-checklist-angular'
@Component({
selector: 'app-onboarding',
standalone: true,
imports: [Checklist],
template: `
<div mol-checklist [items]="items()" [onToggle]="toggle" [title]="'Getting started'"></div>
`,
})
export class Onboarding {
readonly items = signal<ChecklistItem[]>([
{ id: 'profile', label: 'Complete your profile', completed: true },
{ id: 'invite', label: 'Invite a team member', completed: false },
{ id: 'project', label: 'Create your first project', completed: false },
])
readonly toggle = (id: string, next: boolean): void => {
this.items.update((items) =>
items.map((item) => (item.id === id ? { ...item, completed: next } : item)),
)
}
}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular onboarding checklist with checkboxes and overall progress bar.
Exports <Checklist> and the ChecklistItem type. It is the Angular
counterpart of @molecule/app-checklist-react: the same props (React
names), the same DOM for the same input, and the same onToggle calls, so
an app switches framework by changing only the package name in its imports.
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, signal } from '@angular/core'
import { Checklist, type ChecklistItem } from '@molecule/app-checklist-angular'
@Component({
selector: 'app-onboarding',
standalone: true,
imports: [Checklist],
template: `
<div mol-checklist [items]="items()" [onToggle]="toggle" [title]="'Getting started'"></div>
`,
})
export class Onboarding {
readonly items = signal<ChecklistItem[]>([
{ id: 'profile', label: 'Complete your profile', completed: true },
{ id: 'invite', label: 'Invite a team member', completed: false },
{ id: 'project', label: 'Create your first project', completed: false },
])
readonly toggle = (id: string, next: boolean): void => {
this.items.update((items) =>
items.map((item) => (item.id === id ? { ...item, completed: next } : item)),
)
}
}
Type
feature
Installation
npm install @molecule/app-checklist-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
ChecklistItem
A single item in the checklist, tracking its label, description, and
completion state. Node-valued label/description arrive as a template
(the conformance kit's data-prop node value), or as plain text.
interface ChecklistItem {
/** Stable identity, used as the list key and the checkbox `aria-label` fallback. */
id: string
/** Item label: text, or a template. */
label: string | TemplateRef<unknown>
/** Optional description / hint shown under the label: text, or a template. */
description?: string | TemplateRef<unknown>
/** Completion state. */
completed: boolean
/** When true, the item is rendered disabled and uncheckable. */
disabled?: boolean
}
ChecklistProps
Props accepted by Checklist — the same props
@molecule/app-checklist-react accepts. The node-valued title is
projected in Angular ([slot=title]) as well as accepted as a text input.
interface ChecklistProps {
/** The checklist items, rendered in order. */
items: ChecklistItem[]
/** Called when an item is toggled, with its id and the checkbox's new state. */
onToggle: (id: string, next: boolean) => void
/** Show overall progress bar above the list. Defaults to true. */
showProgress?: boolean
/** Optional title above the checklist: text, or `[slot=title]` content. */
title?: unknown
/** Extra classes on the outer wrapper. */
className?: string
}
Classes
Checklist
Checklist component.
Onboarding-style checklist with checkboxes, optional descriptions and an
overall progress bar derived from items. The host IS the root <div>
(div[mol-checklist]), matching React's root exactly. Same props (React
names), same DOM, same onToggle(id, next) calls as
@molecule/app-checklist-react's Checklist. A node-valued title is
projected ([slot=title]); a string input renders as text. Node-valued
label/description on an item arrive as templates and render through
NgTemplateOutlet. The component is fully controlled: it never mutates
completed; persist the toggle in onToggle(id, next) and pass updated
items again.
@Component({
selector: 'div[mol-checklist]',
standalone: true,
imports: [Checkbox, NgTemplateOutlet],
hostDirectives: [MolPlacement],
inputs: ['items', 'onToggle', 'showProgress', 'title', 'className'],
host: {
'[class]': 'classes()',
},
// prettier-ignore
template: `<h3 #titleEl [class]="titleClasses()">@if (hasTextTitle()) {<ng-container>{{ title }}</ng-container>}@if (titleTemplate()) {<ng-container [ngTemplateOutlet]="titleTemplate()"></ng-container>}<ng-content select="[slot=title]"></ng-content></h3>@if (showProgressEnabled()) {<div [class]="cm().stack(1)"><div [class]="cm().flex({ justify: 'between', align: 'center' })"><span [class]="cm().textSize('xs')">{{ progressText() }}</span><span [class]="cm().cn(cm().textSize('xs'), cm().fontWeight('semibold'))">{{ pct() }}%</span></div><div [class]="cm().cn(cm().progress(), cm().progressHeight('sm'))"><div [class]="cm().cn(cm().progressBar(), cm().progressColor('primary'))" [style.width]="pct() + '%'"></div></div></div>}<ul [class]="cm().stack(2)">@for (item of items; track item.id) {<li [class]="cm().flex({ align: 'start', gap: 'sm' })"><span [class]="cm().shrink0"><div mol-checkbox [checked]="item.completed" [disabled]="item.disabled" [attr.aria-label]="ariaLabel(item)" (change)="toggle(item, $event)"></div></span><div [class]="cm().cn(cm().flex1, cm().stack(0))"><span [class]="labelClasses(item)" [style.text-decoration]="item.completed ? 'line-through' : null" [style.opacity]="item.completed ? 0.6 : null">@if (isText(item.label)) {<ng-container>{{ item.label }}</ng-container>}@else {<ng-container [ngTemplateOutlet]="templateOf(item.label)"></ng-container>}</span>@if (item.description) {<span [class]="cm().textSize('xs')">@if (isText(item.description)) {<ng-container>{{ item.description }}</ng-container>}@else {<ng-container [ngTemplateOutlet]="templateOf(item.description)"></ng-container>}</span>}</div></li>}</ul>`,
})
export class Checklist {
/** The checklist items, rendered in order. */
items: ChecklistItem[] = []
/** Called when an item is toggled, with its id and the checkbox's new state. */
onToggle?: (id: string, next: boolean) => void
/** Show the progress block (defaults to true at read time). */
showProgress?: boolean
/** Optional title: text, or projected `[slot=title]` content. */
title?: unknown
/** Extra classes on the outer wrapper. */
className?: string
/** The `<h3>` (always in the template; detached while it has nothing to render). */
@ViewChild('titleEl', { static: true }) private titleEl?: ElementRef<HTMLHeadingElement>
/** i18n state; its `t` reads the provider on every call. */
private readonly i18n = useTranslation()
/**
* Keeps the `<h3>` on the page only while it renders a title input, a title
* template or projected `[slot=title]` content, re-decided whenever any of
* them changes (a title taken away and given back included).
*/
constructor() {
usePlacement((hasContent) => {
const el = this.titleEl?.nativeElement
setElementPresent(
el,
this.hasTextTitle() || this.titleTemplate() !== null || (el ? hasContent(el) : false),
)
})
}
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* Computes the root class list.
* @returns The class string.
*/
classes(): string {
return this.cm().cn(this.cm().stack(3), this.className)
}
/**
* Computes the title's class list.
* @returns The class string.
*/
titleClasses(): string {
return this.cm().cn(this.cm().textSize('base'), this.cm().fontWeight('semibold'))
}
/**
* Computes one item label's class list (React's weight switch).
* @param item - The checklist item.
* @returns The class string.
*/
labelClasses(item: ChecklistItem): string {
return this.cm().cn(
this.cm().textSize('sm'),
item.completed ? this.cm().fontWeight('medium') : this.cm().fontWeight('semibold'),
)
}
/**
* The number of items.
* @returns The item count.
*/
total(): number {
return this.items.length
}
/**
* The number of completed items.
* @returns The completed count.
*/
done(): number {
return this.items.filter((item) => item.completed).length
}
/**
* The completion percentage (0 for an empty list).
* @returns The rounded percentage.
*/
pct(): number {
return this.total() === 0 ? 0 : Math.round((this.done() / this.total()) * 100)
}
/**
* The translated progress summary.
* @returns The progress text.
*/
progressText(): string {
return this.i18n.t(
'checklist.progress',
{ done: this.done(), total: this.total() },
{ defaultValue: '{{done}} of {{total}} complete' },
)
}
/**
* React's `showProgress = true` default: only an explicit `false` hides it.
* @returns Whether the progress block renders.
*/
showProgressEnabled(): boolean {
return this.showProgress !== false
}
/**
* Whether the title is a non-empty text input.
* @returns True when the title input renders as text.
*/
hasTextTitle(): boolean {
return typeof this.title === 'string' && this.title !== ''
}
/**
* The title's template, when the title arrives as a node value.
* @returns The template, or null.
*/
titleTemplate(): TemplateRef<unknown> | null {
return this.templateOf(this.title)
}
/**
* Whether a value is plain text (React renders it as text, not as nodes).
* @param value - A label, description or title.
* @returns True when the value is a string.
*/
isText(value: unknown): value is string {
return typeof value === 'string'
}
/**
* Narrows a value to an embedded template.
* @param value - A label, description or title.
* @returns The template, or null.
*/
templateOf(value: unknown): TemplateRef<unknown> | null {
return value instanceof TemplateRef ? value : null
}
/**
* React's `aria-label`: the label text when it is a plain string, else the item id.
* @param item - The checklist item.
* @returns The accessible name.
*/
ariaLabel(item: ChecklistItem): string {
return typeof item.label === 'string' ? item.label : item.id
}
/**
* React's controlled-checkbox `onChange`: report the input's new state.
* @param item - The toggled item.
* @param event - The click event React's checkbox change fires with.
*/
toggle(item: ChecklistItem, event: Event): void {
const target = event.target as HTMLInputElement
this.onToggle?.(item.id, target.checked)
}
}
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
The progress line uses the i18n key checklist.progress ({{done}},
{{total}}), translated by the @molecule/app-locales-checklist companion
bond. label/description/title are consumer-provided nodes — pass
translated strings via t(). The component is fully controlled: it never
mutates completed; persist the toggle in onToggle(id, next) and pass
updated items again.
Translations
Translation strings are provided by @molecule/app-locales-checklist.