Skip to content

CdsDescription

New in v4.0

A description is muted text under the label of a field. It clarifies what to enter and in what format, so the label can stay short.

Storybook GitLab
Test coverage: 100% — good coverage
API in specs
4 / 4 props, events, slots and exposed members with a test
Test cases
8 unit · 0 browser
Known bugs
1 pinned by an it.fails test
Code coverage
100% lines · 100% branches measured in v4.0.0-alpha.13
A11y (axe)
no violations in 3 stories measured in v4.0.0-alpha.11

Inputs already have the description built in — the description prop of CdsTextInput and the other controls. A standalone CdsDescription is needed for groups of fields and for your own controls. For the label of a field take CdsLabel, for the messages under a field take CdsMessages.

Variations ​

Text ​

The text prop sets the content. The default slot adds arbitrary markup to it — a highlighted input format, for example.

Tag ​

By default the description renders as a div tag. The tag prop changes the tag — to p, for example, when the description lives inside the text of the page.

Scenarios ​

An explanation for a group of fields ​

A group of checkboxes has no description of its own, so the label and the explanation are assembled by hand: CdsLabel names the group, CdsDescription explains what to pick.

API ​

Props

NameTypeDefaultDescription
contentstring | number | undefined—Content displayed in the component.
tagstring | JSXComponent<any> | undefined'div'Custom HTML tag or component to render
textstring | number | undefined—Text displayed in the component.

Slots

NameTypeDescription
defaultanyText of the description