Description List
The <smart-description-list> component renders a list of label/value pairs (a <dl> with <dt>/<dd> rows) with optional title, description, per-item value/action template slots, and bottom attachments/footer slots. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract DescriptionListBaseComponent defines the shared API — optional IDescriptionListOptions and cssClass (alias class). DescriptionListStandardComponent is a barebones placeholder concrete implementation. DescriptionListComponent is the public wrapper that renders DescriptionListStandardComponent by default and accepts a custom replacement via DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN.
Usage
<smart-description-list [options]="options()" />
@if (editedField(); as field) {
<p>Editing: {{ field }}</p>
}
<ng-template #editEmail>
<smart-button [options]="updateEmail">Update</smart-button>
</ng-template>
The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.
Components
DescriptionListComponent (<smart-description-list>)
Main wrapper component. Renders DescriptionListStandardComponent by default. When DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet.
DescriptionListStandardComponent (<smart-description-list-standard>)
Barebones placeholder concrete implementation. Renders a wrapper <div> containing an optional <h3 class="title">, optional <p class="description">, and a <dl> with one <div class="item"> per item. Each item renders a <dt> (label) and a <dd> whose content is either the static value string or the valueTpl template, optionally followed by actionTpl inside <span class="action">. Bottom slots attachmentsTpl and footerTpl render in <div class="attachments"> and <div class="footer"> respectively. The external cssClass is applied to the root wrapper. It does not include any visual styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.
DescriptionListBaseComponent (abstract)
Abstract base directive for extending custom description-list implementations. Exposes options as an InputSignal<IDescriptionListOptions | undefined> and cssClass as an InputSignal<string> (with alias class).
API
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
options | InputSignal<IDescriptionListOptions | undefined> | - | Optional configuration (title, description, items, attachments/footer slot templates) |
class | InputSignal<string> | '' | External CSS classes (alias for cssClass) |
IDescriptionListOptions
All fields are optional. Both the standard and the preset read every field; a section renders only when its string or template is set.
| Field | Type | Default | Description |
|---|---|---|---|
title | string | - | Heading above the list. |
description | string | - | Text under the heading. |
items | IDescriptionListItem[] | [] | The rows. |
attachmentsTpl | TemplateRef<unknown> | - | A section after the rows (e.g. a file list). |
footerTpl | TemplateRef<unknown> | - | A section at the end. |
IDescriptionListItem
| Field | Type | Default | Description |
|---|---|---|---|
label | string | required | The term (<dt>). |
value | string | - | The value as text. |
valueTpl | TemplateRef<unknown> | - | The value as a template; wins over value. |
actionTpl | TemplateRef<unknown> | - | An action next to the value. |
DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN
InjectionToken that allows replacing the default DescriptionListStandardComponent with a custom implementation. Provide a Type<DescriptionListBaseComponent> to override. The wrapper passes options and the class value to the registered component (under class when it keeps the base's alias, under cssClass when it redeclares the input without it).
Extending the base class
import { NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
computed,
ViewEncapsulation,
} from '@angular/core';
import {
DescriptionListBaseComponent,
DescriptionListComponent,
DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN,
IDescriptionListOptions,
} from '@smartsoft001/angular';
/**
* A custom description list built on `DescriptionListBaseComponent`.
*
* The base contributes the `options` and `class` inputs. Each item carries
* either a plain `value` or a `valueTpl` template, so an implementation that
* wants to stay compatible with the standard one projects both.
*/
@Component({
selector: 'docs-custom-description-list',
template: `
<div [class]="containerClasses()">
@if (options()?.title) {
<h3 class="docs-description-list__title">{{ options()!.title }}</h3>
}
@if (options()?.description) {
<p class="docs-description-list__description">
{{ options()!.description }}
</p>
}
<dl>
@for (item of options()?.items ?? []; track $index) {
<div class="docs-description-list__row">
<dt>{{ item.label }}</dt>
<dd>
@if (item.valueTpl) {
<ng-container [ngTemplateOutlet]="item.valueTpl" />
} @else {
{{ item.value }}
}
</dd>
</div>
}
</dl>
</div>
`,
imports: [NgTemplateOutlet],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomDescriptionListComponent extends DescriptionListBaseComponent {
// `cssClass` comes from the base (alias `class`): the wrapper hands the
// consumer's class to it under that name.
containerClasses = computed(() =>
['docs-description-list', this.cssClass()].filter(Boolean).join(' '),
);
}
/**
* Registering the implementation against
* `DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN` makes every
* `<smart-description-list>` in this injector render it instead of the
* standard variation.
*/
@Component({
selector: 'docs-description-list-custom-example',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [DescriptionListComponent],
providers: [
{
provide: DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN,
useValue: CustomDescriptionListComponent,
},
],
template: `<smart-description-list
[options]="options"
class="docs-description-list--compact"
/>`,
})
export class DescriptionListCustomExampleComponent {
options: IDescriptionListOptions = {
title: 'Applicant information',
description: 'Personal details and application.',
items: [
{ label: 'Full name', value: 'Margot Foster' },
{ label: 'Application for', value: 'Backend Developer' },
{ label: 'Salary expectation', value: '$120,000' },
],
};
}
Preset
DescriptionListPresetComponent (<smart-description-list-preset>) is a styled drop-in replacement for the barebones standard component. It renders the same structure with Tailwind utility classes (every class carries the smart: prefix, with explicit smart:dark:* twins):
- Optional header (
data-role="header"): title as<h3>(text-base font-semibold text-gray-900 dark:text-white) and description as<p>(text-sm text-gray-500 dark:text-gray-400). Rendered only when title or description is set. - List (
data-role="list"): the<dl>carriesdivide-y divide-gray-200 dark:divide-gray-700; the externalcssClassis merged onto it. - Rows (
data-role="row"):grid py-3 sm:grid-cols-3 sm:gap-4with<dt>(data-role="term",text-sm font-medium text-gray-500 dark:text-gray-400) and<dd>(data-role="value",text-sm text-gray-900 dark:text-white sm:col-span-2).valueTplwins overvalue;actionTplrenders right-aligned insidedata-role="action". - Optional
attachmentsTpl(data-role="attachments") andfooterTpl(data-role="footer") render as separate sections below the list.
The preset declares cssClass without the class alias, so bind [cssClass] when you use the <smart-description-list-preset> selector directly; class on <smart-description-list> reaches it through the wrapper. Register it for DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN to restyle every <smart-description-list>, or register every preset at once with provideSmartPresets().
No new IDescriptionListOptions fields are introduced; the preset consumes the existing API. Its class recipes are internal (not exported from @smartsoft001/angular).
Source
The component lives in packages/shared/angular/src/lib/components/description-list and is documented for Claude Code by the angular-components-description-list skill.
SmartDescriptionList renders a list of label / value pairs (a <dl>), with an optional title and description above it and attachments and footer slots below it. A row's valueTpl node wins over its value text, and actionTpl adds an action (e.g. an "Update" link) next to the value. SmartDescriptionListStandard is unstyled; SmartDescriptionListPreset renders the header, a divided list and the extra sections styled.
Usage
import { useState } from 'react';
import {
IDescriptionListOptions,
SmartButton,
SmartDescriptionList,
} from '@smartsoft001/react';
export function DescriptionListUsageExample() {
const [editedField, setEditedField] = useState<string | null>(null);
const options: IDescriptionListOptions = {
title: 'Applicant information',
description: 'Personal details and application.',
items: [
{ label: 'Full name', value: 'Margot Foster' },
{ label: 'Application for', value: 'Backend Developer' },
{
label: 'Email address',
value: 'margotfoster@example.com',
actionTpl: (
<SmartButton
options={{
variant: 'secondary',
size: 'sm',
click: () => setEditedField('email'),
}}
>
Update
</SmartButton>
),
},
{ label: 'Salary expectation', value: '$120,000' },
],
};
return (
<>
<SmartDescriptionList options={options} />
{editedField && <p>Editing: {editedField}</p>}
</>
);
}
The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.
Exports
All from @smartsoft001/react.
| Export | Kind | What it is |
|---|---|---|
SmartDescriptionList | component | Renders the implementation registered as components['description-list'] on SmartProvider, SmartDescriptionListStandard by default. |
SmartDescriptionListPreset | component | Preset-styled description list. |
SmartDescriptionListStandard | component | The default description list rendering: an unstyled title, description, a <dl> of label/value items (valueTpl wins over value, actionTpl follows the value) and the attachments and footer slots. |
The preset's class helpers (getDescriptionListListClasses, DESCRIPTION_LIST_TITLE_CLASSES, DESCRIPTION_LIST_DESCRIPTION_CLASSES, DESCRIPTION_LIST_LIST_CLASSES, DESCRIPTION_LIST_ROW_CLASSES, DESCRIPTION_LIST_TERM_CLASSES, DESCRIPTION_LIST_VALUE_CLASSES, DESCRIPTION_LIST_ACTION_CLASSES, DESCRIPTION_LIST_ATTACHMENTS_CLASSES, DESCRIPTION_LIST_FOOTER_CLASSES) are exported too, for a custom implementation that wants the preset look.
Props and Types
SmartDescriptionListProps
| Prop | Type | Default | Description |
|---|---|---|---|
options? | IDescriptionListOptions | — | Header, rows and extra sections. |
className? | string | — | Classes on the root element (on the <dl> in the preset). |
IDescriptionListOptions
| Field | Type | Default | Description |
|---|---|---|---|
title? | string | — | Heading above the list. |
description? | string | — | Text under the heading. |
items? | IDescriptionListItem[] | [] | The rows. |
attachmentsTpl? | ReactNode | — | A section after the rows (e.g. a file list). |
footerTpl? | ReactNode | — | A section at the end. |
IDescriptionListItem
| Field | Type | Default | Description |
|---|---|---|---|
label | string | required | The term. |
value? | string | — | The value as text. |
valueTpl? | ReactNode | — | The value as a node; wins over value. |
actionTpl? | ReactNode | — | An action next to the value. |
Replacing the Implementation
SmartDescriptionList renders the component registered under the 'description-list' key of SmartProvider's components, and SmartDescriptionListStandard when nothing is registered there. Every SmartDescriptionList below the provider then renders the registered component, which receives the same props.
SmartDescriptionListPreset is the styled (preset) implementation: register it under the 'description-list' key of SmartProvider's components, render it directly in place of SmartDescriptionList, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.
import {
IDescriptionListOptions,
SmartDescriptionList,
SmartDescriptionListProps,
SmartProvider,
} from '@smartsoft001/react';
/**
* A custom description list taking `SmartDescriptionListProps`.
*
* Each item carries either a plain `value` or a `valueTpl` node, so an
* implementation that wants to stay compatible with the standard one renders
* both.
*/
export function CustomDescriptionList({
options,
className,
}: SmartDescriptionListProps) {
return (
<div
className={['docs-description-list', className].filter(Boolean).join(' ')}
>
{options?.title && (
<h3 className="docs-description-list__title">{options.title}</h3>
)}
{options?.description && (
<p className="docs-description-list__description">
{options.description}
</p>
)}
<dl>
{(options?.items ?? []).map((item, index) => (
<div key={index} className="docs-description-list__row">
<dt>{item.label}</dt>
<dd>{item.valueTpl ?? item.value}</dd>
</div>
))}
</dl>
</div>
);
}
// A module constant: a new object on every render would change the context.
const components = { 'description-list': CustomDescriptionList };
const options: IDescriptionListOptions = {
title: 'Applicant information',
description: 'Personal details and application.',
items: [
{ label: 'Full name', value: 'Margot Foster' },
{ label: 'Application for', value: 'Backend Developer' },
{ label: 'Salary expectation', value: '$120,000' },
],
};
// Every <SmartDescriptionList> below the provider renders CustomDescriptionList.
export function DescriptionListCustomExample() {
return (
<SmartProvider components={components}>
<SmartDescriptionList
options={options}
className="docs-description-list--compact"
/>
</SmartProvider>
);
}
Styling
SmartDescriptionListPresethas no wrapper element: header,<dl>, attachments and footer render side by side, andclassNamelands on the<dl>. It carriessmart:dark:variants.SmartDescriptionListStandardis unstyled markup.
Source
The component lives in packages/shared/react/src/lib/components/description-list and is documented for Claude Code by the react-components-description-list skill.