DescriptionList
Read-only label / value rows: customer profile in the right panel, ticket details, call info, merge previews. Labels sit in a fixed-width gray column, values are 12pt and wrap, and can carry a copy button; empty values show a placeholder. Not a form field: use Field for editable values.
Status: experimental · Components: DescriptionList, DescriptionItem, CopyButton, RevealableValue, CopyText
Import
Section titled “Import”import { DescriptionList, DescriptionItem, CopyButton, RevealableValue, CopyText } from 'nacre'Give plain-text values as value (an empty string shows emptyText, -- by default); copyValue adds a button that appears on row hover or Tab focus on desktop, stays visible on phones, and shows a check for 1.5 seconds after copying. Set the label width and spacing once on DescriptionList.
import { View } from 'nsh'import { DescriptionItem, DescriptionList } from 'nacre'
export function DescriptionListUsage() { return ( <View class="w-[320px] max-w-full"> <DescriptionList testID="desc-usage"> <DescriptionItem label="Chat ID" value="C202611050001" copyValue="C202611050001" testID="desc-usage-id" copyTestID="desc-usage-copy" /> <DescriptionItem label="Channel" value="Longbridge app" /> <DescriptionItem label="Started at" value="2026-11-05 09:12:30" /> <DescriptionItem label="Ended at" value={undefined} testID="desc-usage-empty" /> </DescriptionList> </View> )}Examples
Section titled “Examples”Reveal, hide and copy a masked field
Section titled “Reveal, hide and copy a masked field”Pass the permitted display value and masked state. Loading disables the toggle, and masking removes the copy action. Use indicator for a row controlled from its menu. The application owns permissions, requests and customer changes.
import { signal } from 'nsh'import { RevealableValue } from 'nacre'
export function RevealableContact() { const masked = signal(true) return ( <RevealableValue testID="demo-secret" copyTestID="demo-secret-copy" copyable value={masked() ? '+852 6****42' : '+852 61234542'} masked={masked()} toggleLabel={masked() ? 'Show number' : 'Hide number'} onToggle={() => masked.set(!masked())} /> )}Custom values, long text and masking
Section titled “Custom values, long text and masking”Put tags, links and the like in children, laid out in a wrapping row; long text wraps and the label stays on the first line. A masked value gets no copy button (copying a masked value is pointless), and its accessible name adds “masked”; actions such as reveal or dial go in children.
import { View } from 'nsh'import { Button, DescriptionItem, DescriptionList, Tag } from 'nacre'
export function DescriptionListRich() { return ( <View class="w-[320px] max-w-full"> <DescriptionList testID="desc-rich"> <DescriptionItem label="Status" testID="desc-rich-status"> <Tag variant="dot" size="md" label="In progress" tone="info" /> <Tag label="Major" tone="destructive" /> </DescriptionItem> <DescriptionItem label="Merged tickets"> <Button variant="link" size="inline" onPress={() => {}}> T20261101002 </Button> <Button variant="link" size="inline" onPress={() => {}}> T20261101007 </Button> </DescriptionItem> <DescriptionItem label="Customer demand" value="The customer says the funds from a winning HK IPO allotment did not arrive on time and asks for an explanation and compensation for lost interest." testID="desc-rich-long" /> <DescriptionItem label="Phone" value="138****5678" copyValue="138****5678" masked testID="desc-rich-masked" copyTestID="desc-rich-masked-copy" /> </DescriptionList> </View> )}Compact and single-line
Section titled “Compact and single-line”density=“compact” uses 18pt rows 2pt apart (the default comfortable uses 20pt rows 6pt apart, so text rows match rows with tags), for a few plain-text rows in a preview box or card; keep the default for rows with Tags; for long English labels widen labelWidth or use truncateLabel (single line, full text on hover). Use truncate for IDs and numbers that shouldn’t wrap.
import { View } from 'nsh'import { DescriptionItem, DescriptionList } from 'nacre'
export function DescriptionListDensity() { return ( <View class="flex-row flex-wrap gap-8"> <View class="w-[300px] max-w-full rounded-lg bg-secondary px-3 py-2.5"> <DescriptionList testID="desc-compact" density="compact" labelWidth={92}> <DescriptionItem label="Main ticket" value="T20261101002" /> <DescriptionItem label="Handler" value="Jiayi Lin" /> <DescriptionItem label="Related records" value="12" /> </DescriptionList> </View> <View class="w-[260px] max-w-full"> <DescriptionList testID="desc-truncate" labelWidth={96} truncateLabel> <DescriptionItem label="Contact center call ID" value="a1b2c3d4-e5f6-7890-abcd-ef1234567890" copyValue="a1b2c3d4-e5f6-7890-abcd-ef1234567890" truncate testID="desc-truncate-value" /> <DescriptionItem label="Customer number" value="+852 9123 4567" copyValue="+852 9123 4567" truncate /> </DescriptionList> </View> </View> )}Click-to-copy text: CopyText
Section titled “Click-to-copy text: CopyText”IDs and values in fields or cells: the whole text is a button, so clicking the text or the icon copies. Hover tints it, pressing tints it deeper, and the icon turns into a check for 1.5 seconds after copying. Keep other buttons (a reveal eye) outside CopyText.
import { Text, View } from 'nsh'import { CopyText, TEXT_SIZE } from 'nacre'
export function CopyTextUsage() { return ( <View class="flex-row items-center gap-4"> <CopyText value="1006664209" label="Copy customer ID" testID="copy-text-usage"> <Text class={`${TEXT_SIZE.body} tabular-nums text-foreground`}>1006664209</Text> </CopyText> <CopyText value="H17225823" testID="copy-text-account"> <Text class={`${TEXT_SIZE.small} tabular-nums text-muted-foreground`}>H17225823</Text> </CopyText> </View> )}Standalone CopyButton
Section titled “Standalone CopyButton”Copy next to an ID or in a table cell. Always visible by default; reveal shows it on hover or focus on desktop and keeps it visible on phones. Pass onError to log clipboard failures.
Phone: On phones the copy button beside IDs and cells is always visible; tap to copy with a confirmation.
import { View, signal } from 'nsh'import { Button, CopyButton, Tag } from 'nacre'
export function CopyButtonUsage() { const chatId = signal('C202611050001') return ( <View class="group flex-row items-center gap-1"> <Tag label={chatId()} /> <CopyButton value={chatId()} testID="copy-button-usage" /> <CopyButton value={chatId()} label="Copy chat ID" reveal testID="copy-button-reveal" /> <Button size="sm" variant="ghost" testID="copy-next-chat" onPress={() => chatId.set(chatId().endsWith('1') ? 'C202611050002' : 'C202611050001')}> Switch chat </Button> </View> )}Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| Tab | Focus the copy button (a reveal button shows while focused) |
| Space / Return | Copy; the accessible name changes to “Copied” |
Accessibility
Section titled “Accessibility”- Labels and values are text and are read in order; an empty value reads its placeholder (
--). - The copy button’s accessible name is “Copy” by default; with several on one screen, pass copyLabel to say what it copies (“Copy chat ID”).
- A masked value adds “masked” to its accessible name instead of leaving people to guess from asterisks.
Do / Don’t
Section titled “Do / Don’t”Do
- Lay out read-only fields in the right panel, details and previews with it
- Use one DescriptionList per group of rows to fix the label width
- Widen labelWidth or use truncateLabel for long English labels, and check English and Japanese
Don’t
- Use it as a form (use Field for editable values)
- Write your own clipboard call and check (use copyValue or CopyButton)
- Put a copy button on a masked value
Property descriptions follow the Chinese source comments.
DescriptionList
Section titled “DescriptionList”| Prop | Type | Default | Description |
|---|---|---|---|
labelWidth |
number |
— | 标签列宽(pt),默认 72;中文四字标签 64–72,英文长标签放宽到 96 或用 truncateLabel |
density |
'compact' | 'comfortable' |
'comfortable' |
comfortable(默认)行高 20(文字行与带标签的行一样高)、行间 6,右栏与详情;compact 行高 18、行间 2,预览块、卡片里的几行纯文字(有 Tag 的行用默认) |
truncateLabel |
boolean |
— | 标签单行截断、悬停看全文;默认放不下时折行(英文长标签不被截掉) |
testID |
string |
— | |
class |
string |
— | |
children |
JSX.Element |
— |
* required
DescriptionItem
Section titled “DescriptionItem”| Prop | Type | Default | Description |
|---|---|---|---|
label * |
string |
— | |
value |
string |
— | 纯文字的值:12pt、数字等宽,可折行;空串 / undefined 显示 emptyText(写了这个属性就按文字值排,哪怕值是 undefined)。和 children 二选一 |
children |
JSX.Element |
— | 自定义的值(标签、链接、多段),横排可折行;给了 value 时不渲染 |
copyValue |
string |
— | 值后跟一个小复制钮(悬停整行或键盘聚焦才出现,复制后打勾 1.5 秒),复制的是这个值;空串不出 |
copyLabel |
string |
— | 复制钮的读屏名,默认「复制 + 标签」(「复制客户 ID」):同一列表里多个复制钮读屏分得开 |
emptyText |
string |
'--' |
空值占位,默认 --(弱化灰) |
masked |
boolean |
— | 值已脱敏(含 *):不出复制钮,读屏名补「已脱敏」 |
truncate |
boolean |
— | value 单行截断、悬停看全文(编号、号码这类不该折行的值) |
labelWidth |
number |
— | 只这一行改标签宽(一般在 DescriptionList 上统一给) |
testID |
string |
— | 值的 testID:value 时在文字上,children 时在值容器上 |
copyTestID |
string |
— |
* required
CopyButton
Section titled “CopyButton”| Prop | Type | Default | Description |
|---|---|---|---|
value * |
string |
— | 写进剪贴板的值;空串不复制 |
label |
string |
— | 读屏名与悬停提示,默认「复制」 |
copiedLabel |
string |
— | 复制成功后 1.5 秒内的读屏名,默认「已复制」 |
onError |
(error: unknown) => void |
— | 复制失败时通知调用方;不会显示成功对勾 |
testID |
string |
— | |
reveal |
boolean |
— | 桌面端所在 group 悬停或自己聚焦时出现;复制后的对勾保持可见。手机一直显示 |
* required
RevealableValue
Section titled “RevealableValue”| Prop | Type | Default | Description |
|---|---|---|---|
value * |
string |
— | 当前允许显示的内容。请求与权限由调用方管理。 |
masked * |
boolean |
— | |
toggleLabel |
string |
— | |
onToggle |
() => void |
— | |
indicator |
boolean |
— | 由行菜单负责切换时,用非交互图标显示当前状态。 |
loading |
boolean |
— | |
copyable |
boolean |
— | |
hoverCopy |
boolean |
— | |
truncate |
boolean |
— | |
textClass |
string |
— | |
testID |
string |
— | |
copyTestID |
string |
— |
* required
CopyText
Section titled “CopyText”| Prop | Type | Default | Description |
|---|---|---|---|
value * |
string |
— | 写进剪贴板的值;空串时只显示内容、不可点 |
children * |
JSX.Element |
— | 显示的内容(通常是一段 Text);字号、颜色、截断由调用方给 |
label |
string |
— | 读屏名:「复制 客户 ID」;默认「复制」 |
copiedLabel |
string |
— | 复制成功后 1.5 秒内的读屏名与提示,默认「已复制」 |
testID |
string |
— | |
class |
string |
— | 根节点的布局逃生口(flex、宽、外边距),不改颜色 |
* required