Metadata
Read-only label and value pairs that describe one item: its status, owner, dates, tags. The value is a slot, so it takes text or any component (Badge, Avatar with a name, a link, a small Button). Horizontal puts the labels in one column beside the values; vertical puts each label above its value.
Preview
Usage
When to use
- Show read-only facts about one item, each with its name: status, owner, dates, tags, an ID.
- A details panel beside the main content, with the names in one column and the values lined up next to them.
- A row of key facts, each name above its value, such as the plan, seats and renewal date of a subscription.
When not to use
- Values the user edits. Use Field, which links the label to the control.
- Many records that share the same names, such as a list of projects. Use Table, with the names once in its header.
- A status alone next to an item, with no name for it. Use Badge.
Platform support
What each platform has, from the spec. A selected platform is highlighted.
| Name | Web | iOS | Android | Note |
|---|---|---|---|---|
| orientation | Yes | Yes | Yes | |
| label | Yes | Yes | Yes | |
| leadingIcon | Yes | Yes | Yes |
Variants
orientation
On Metadata, sets every item. horizontal: labels in one column beside the values, for a details panel. vertical: each label above its value, for a narrow column or a row of key facts. On one MetadataItem, overrides it for that item, such as a long description under horizontal rows.
Examples
Default
With icons
The icon names nothing on its own, so it is hidden from screen readers. Every label gets one, or none does.
Key facts in a row
Vertical items on a grid of three columns: each label above its value.
A long value under the rows
One vertical item in a horizontal list takes the full width, for a value that needs the room.
With an action
A value can hold a control. The label does not name it, so the button carries its own words.
Do and don't
Do
- Use Metadata for read-only facts about one item: status, owner, dates, tags, IDs.
- Keep labels short: one to three words, sentence case, no colon.
- Give every item a value. When there is none, write it: None, Not set.
- Pick horizontal for a details panel; vertical for a narrow column, or for a row of key facts with grid-cols-* on Metadata.
- Wrap a sentence that holds a link in a span, so it stays one line of running text instead of separate pieces.
Don't
- Don't put a form control in a value to edit it. A value the user fills in needs Field, with a label linked to the control.
- Don't use Metadata for many records that share the same labels; use Table.
- Don't make labels bold or colored. The value is what the user reads; the label only names it.
- Don't mix items with and without icons in one list.
Props
| Name | Type | Values | Default | Description |
|---|---|---|---|---|
| orientation | enum | horizontal | vertical | horizontal | On Metadata, sets every item. horizontal: labels in one column beside the values, for a details panel. vertical: each label above its value, for a narrow column or a row of key facts. On one MetadataItem, overrides it for that item, such as a long description under horizontal rows. |
| label required | node | - | - | Set on MetadataItem. The name of the value: Status, Owner, Created. One to three words, sentence case, no colon. |
| leadingIcon | node | - | - | Set on MetadataItem. Decorative Tabler icon before the label: size={16}. Leave it out for no icon. Give every item in a list an icon, or none. |
Not generated: Metadata (the list).
Slots
| Name | Required | Description |
|---|---|---|
| items | yes | One MetadataItem per pair. |
| value | yes | The children of MetadataItem: text, or components such as a Badge, an Avatar with the name after it, a link or a small Button. Several components sit in a row that wraps. |
Anatomy
| Part | Description |
|---|---|
| root | Metadata: the dl. Horizontal: a two-column grid, labels in the first column as wide as the longest label (at most 40% of the list) and values in the second. Vertical: a grid of one column, items gap-lg; add grid-cols-* to lay them in a row. |
| item | MetadataItem: one label and value pair, a div around a dt and a dd. Horizontal: a row on the list's two columns (subgrid). Vertical: the label above the value, gap-xs. |
| label | The dt: 14px secondary text, with the optional icon before it (gap-xs). Horizontal: at least one sm control tall, text centered. |
| icon | Optional leading icon in the label: 16px, secondary icon color, level with the first line of the label, hidden from screen readers. |
| value | The dd: 14px primary text in a row that wraps (gap-sm), so text and components line up. Horizontal: at least one sm control tall, content centered, so a line of text and a 28px button both sit level with the label. |
Accessibility
Role: term and definition (description list)
- Metadata is a description list: each label is a dt and its value a dd, grouped in a div, so screen readers read every label with its value and announce the number of items.
- The leading icon is decorative and hidden from screen readers; the label text names the value.
- To name the whole list, put a heading above it and point aria-labelledby on Metadata at the heading.
- Controls inside a value (a link, a Button) keep their own name and focus order. A label is not a control's name: give an icon-only button its own aria-label.
Install
npx werewolf-ui add metadataRun npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.