Descriptions

A read-only list of labels and their values.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrDescriptionItem, WrDescriptions } from 'ngwr/descriptions';

@Component({ imports: [WrDescriptionItem, WrDescriptions] })
export class MyComponent {}

Default

Each label sits above its value with no rules, which suits a card that has its own frame.

<wr-descriptions title="Account">
  <wr-description-item label="Name">Ada Lovelace</wr-description-item>
  <wr-description-item label="Email">[email protected]</wr-description-item>
</wr-descriptions>
Account
Name
Ada Lovelace
Email
Joined
2024-03-12

Inline + bordered

inline puts each label beside its value and bordered draws rules; each also works alone.

<wr-descriptions title="Account" inline bordered>
  <wr-description-item label="Name">Ada Lovelace</wr-description-item>
  <wr-description-item label="Email">[email protected]</wr-description-item>
  <wr-description-item label="Joined">2024-03-12</wr-description-item>
</wr-descriptions>
Account
Name
Ada Lovelace
Email
Joined
2024-03-12

Narrow container

With responsive, an inline list stacks when its own container is narrow.

Account
Name
Ada Lovelace
Email
Joined
2024-03-12
<div style="width: 280px"><wr-descriptions responsive inline bordered>…</wr-descriptions></div>

Descriptions API

NameDescriptionTypeDefault
titleOptional title shown above the list.string''
inlineTwo-column rows (label left, value right) instead of stacked.booleanfalse
borderedAdd visible borders around each row.booleanfalse
responsiveReflow inline rows back to a stacked layout when the box itself is narrow (a container query on its own width, not the viewport — so it adapts inside a narrow card or side panel). Makes the box fill its container's width.booleanfalse

Description item API

NameDescriptionTypeDefault
labelThe term shown beside the projected value — "Email", "Created". Keep it a noun: it is read as the name of the value, not as a sentence.string''

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/descriptions's own element.

VariableDefaultDeclared on
--wr-descriptions-bordervar(--wr-border-base).wr-descriptions
--wr-descriptions-font-familyvar(--wr-font-family-base).wr-descriptions
--wr-descriptions-label-font-sizevar(--wr-text-xs).wr-descriptions +1 variant override
--wr-descriptions-label-font-weightvar(--wr-font-weight-medium).wr-descriptions
--wr-descriptions-label-letter-spacingvar(--wr-tracking-wide).wr-descriptions +1 variant override
--wr-descriptions-list-column-gapvar(--wr-space-sm).wr-descriptions +1 variant override
--wr-descriptions-list-row-gapvar(--wr-space-sm).wr-descriptions
--wr-descriptions-radiusvar(--wr-border-radius-base).wr-descriptions
--wr-descriptions-row-gapvar(--wr-space-xs).wr-descriptions
--wr-descriptions-row-padding-xvar(--wr-space-lg).wr-descriptions
--wr-descriptions-row-padding-yvar(--wr-space-md).wr-descriptions
--wr-descriptions-title-font-sizevar(--wr-text-base).wr-descriptions
--wr-descriptions-title-font-weightvar(--wr-font-weight-semibold).wr-descriptions
--wr-descriptions-title-margin-bottomvar(--wr-space-md).wr-descriptions
--wr-descriptions-value-font-sizevar(--wr-text-sm).wr-descriptions
--wr-descriptions-value-line-heightvar(--wr-leading-normal).wr-descriptions

See also