Disclosure
Collapsible content: Disclosure is a group heading with a triangle (with an optional leading icon, count, trailing extras, separate actions outside the button, and the chevron at the start or end), and DisclosureRow is a fully clickable record row that opens to show details. Both handle only the heading row; the caller shows or hides the content from expanded with If or Collapsible.
Status: stable · Components: Disclosure, DisclosureRow
Import
Section titled “Import”import { Disclosure, DisclosureRow } from 'nacre'Controlled expanded + onPress; write the expanded content with pl-[18px] so it aligns with the heading text.
import { Text, View, signal } from 'nsh'import { Disclosure, TEXT_SIZE } from 'nacre'
export function DisclosureUsage() { const open = signal(true) return ( <View class="w-[320px] max-w-full gap-2"> <Disclosure title="QA results" expanded={open()} onPress={() => open.update((v) => !v)} /> <If when={open()}> <Text class={`pl-[18px] ${TEXT_SIZE.small} text-muted-foreground`}>Service attitude 5 · Issue resolved · No prohibited language</Text> </If> </View> )}Examples
Section titled “Examples”Multiple groups
Section titled “Multiple groups”Each group opens and closes on its own; expand the most-used group by default, and put the count in the heading; a disabled group can’t be clicked.
import { Text, View, signal } from 'nsh'import { Disclosure, TEXT_SIZE } from 'nacre'
export function DisclosureGroups() { const result = signal(true) const hits = signal(false) return ( <View class="w-[320px] max-w-full gap-2"> <Disclosure title="Overall result" expanded={result()} onPress={() => result.update((v) => !v)} /> <If when={result()}> <Text class={`pl-[18px] ${TEXT_SIZE.small} text-muted-foreground`}>Chat satisfaction 4.8, first response in 12 s</Text> </If> <Disclosure title="Live matches (3)" expanded={hits()} onPress={() => hits.update((v) => !v)} /> <If when={hits()}> <View class="pl-[18px] gap-1"> {['Account opening', 'Withdrawal', 'Complaint'].map((word) => <Text class={`${TEXT_SIZE.small} text-muted-foreground`}>{`$Matched keyword: ${word}`}</Text>)} </View> </If> <Disclosure title="Disabled group" expanded={false} disabled onPress={() => {}} /> </View> )}Secondary lines
Section titled “Secondary lines”variant=“subtle” + chevron=“end”: a leading icon, a regular-weight muted heading and a chevron at the row end, placed beside body text (reasoning, tools, references). Put a tool’s status icon in trailing, left of the chevron. Give the blocks in one place the same look.
import { Text, View, signal } from 'nsh'import { Disclosure, Icon, TEXT_SIZE } from 'nacre'
export function DisclosureSubtle() { const reasoning = signal(false) const tool = signal(false) const sources = signal(false) return ( <View class="w-[320px] max-w-full gap-1"> <Disclosure testID="subtle-reasoning" variant="subtle" chevron="end" leading={<Icon name="sparkles" size={13} color="muted-foreground" />} title="Thought for 4 s" expanded={reasoning()} onPress={() => reasoning.update((v) => !v)} /> <If when={reasoning()}> <Text class={`pl-3 ml-1.5 border-l border-border ${TEXT_SIZE.small} text-muted-foreground`}>Check the account opening progress first, then whether the documents are complete.</Text> </If> <Disclosure testID="subtle-tool" variant="subtle" chevron="end" leading={<Icon name="wrench" size={13} color="muted-foreground" />} title="query_account_status" trailing={<Icon name="check" size={13} color="muted-foreground" />} expanded={tool()} onPress={() => tool.update((v) => !v)} /> <Disclosure testID="subtle-sources" variant="subtle" chevron="end" leading={<Icon name="file" size={13} color="muted-foreground" />} title="Used 3 sources" expanded={sources()} onPress={() => sources.update((v) => !v)} /> </View> )}Panel section heading
Section titled “Panel section heading”variant=“section” + chevron=“end”: an icon, the heading, a count right after it (suffix) and meta at the row end (trailing, truncated first when narrow), with a hover background behind the chevron.
Phone: variant=“section” + chevron=“end”: icon, title, count (suffix) and trailing meta (truncated first when narrow); tap the row to expand.
import { Text, View, signal } from 'nsh'import { Disclosure, Icon, TEXT_SIZE } from 'nacre'
export function DisclosureSection() { const open = signal(true) return ( <View class="w-[320px] max-w-full gap-2"> <Disclosure testID="section-remark" variant="section" chevron="end" leading={<Icon name="sparkles" size={13} color="muted-foreground" />} title="Service notes" suffix={<Text class={`${TEXT_SIZE.caption} text-muted-foreground tabular-nums`}>3</Text>} trailing={<Text class={`shrink min-w-0 truncate ${TEXT_SIZE.caption} text-muted-foreground tabular-nums`}>Lin Jiayi · 11-24 14:05</Text>} expanded={open()} onPress={() => open.update((v) => !v)} /> <If when={open()}> <Text class={`${TEXT_SIZE.small} text-muted-foreground`}>The customer has submitted proof of address; call back after review.</Text> </If> </View> )}Group heading with an action
Section titled “Group heading with an action”variant=“group”: a list’s group heading, with the count in suffix; an action such as Clear goes in actions, outside the toggle button, so pressing it doesn’t expand or collapse.
import { Text, View, signal } from 'nsh'import { Button, Disclosure, TEXT_SIZE } from 'nacre'
export function DisclosureActions() { const active = signal(true) const ended = signal(true) const endedCount = signal(12) return ( <View class="w-[320px] max-w-full"> <Disclosure testID="group-active" variant="group" class="h-7 px-1.5 rounded-md" title="Active" suffix={<Text class={`${TEXT_SIZE.small} text-muted-foreground tabular-nums`}>5</Text>} expanded={active()} onPress={() => active.update((v) => !v)} /> <Disclosure testID="group-ended" variant="group" class="h-7 px-1.5 rounded-md" title="Ended" suffix={<Text testID="group-ended-count" class={`${TEXT_SIZE.small} text-muted-foreground tabular-nums`}>{String(endedCount())}</Text>} actions={ <If when={endedCount() > 0}> <Button testID="group-ended-clear" variant="subtle" size="xs" onPress={() => endedCount.set(0)}> Clear </Button> </If> } expanded={ended()} onPress={() => ended.update((v) => !v)} /> </View> )}Record rows
Section titled “Record rows”DisclosureRow sits in a card as the head of a call record: the caller lays out the time, tag, status and summary, and places the chevron itself; only one row is expanded at a time.
import { Text, View, signal } from 'nsh'import { DisclosureRow, Icon, Tag, TEXT_SIZE } from 'nacre'
const calls = () => [ { id: 'c1', time: 'Today 14:05', direction: 'Inbound', status: 'Connected', summary: '3 min 12 s · Lin Jiayi · Account opening / Additional documents' }, { id: 'c2', time: 'Yesterday 09:40', direction: 'Outbound', status: 'Not connected', summary: 'Follow-up · Chen Zhiyuan · Withdrawal not received' },]
export function DisclosureRows() { const open = signal<string | null>(null) return ( <View class="w-[320px] max-w-full gap-1.5"> {calls().map((call) => ( <View class="rounded-lg bg-card border border-border"> <DisclosureRow testID={`call-row-${call.id}`} accessibilityLabel={`${call.time} · ${call.direction} · ${call.status}`} expanded={open() === call.id} onPress={() => open.set(open() === call.id ? null : call.id)} > <View class="flex-row items-center gap-1.5"> <Text class={`shrink-0 ${TEXT_SIZE.caption} text-muted-foreground tabular-nums`}>{call.time}</Text> <Tag label={call.direction} /> <View class="flex-1" /> <Text class={`shrink min-w-0 truncate ${TEXT_SIZE.caption} text-muted-foreground`}>{call.status}</Text> <Icon name={open() === call.id ? 'chevron-down' : 'chevron-right'} size={10} color="muted-foreground" /> </View> <Text class={`truncate ${TEXT_SIZE.caption} text-muted-foreground`}>{call.summary}</Text> </DisclosureRow> <If when={open() === call.id}> <View class="px-2.5 pb-2.5"> <Text class={`${TEXT_SIZE.small} text-text-secondary`}>Notes: The customer has submitted proof of address; call back after review.</Text> </View> </If> </View> ))} </View> )}Long heading
Section titled “Long heading”The heading truncates to one line, with the full text on hover; even in a narrow column it doesn’t wrap or grow taller.
Phone: The title truncates to one line and shows in full once expanded; it never wraps or grows taller on narrow screens.
import { Text, View, signal } from 'nsh'import { Disclosure, TEXT_SIZE } from 'nacre'
export function DisclosureLongTitle() { const open = signal(false) return ( <View class="w-[200px] max-w-full gap-2"> <Disclosure title="HK stock account opening · Unresolved · Last 30 days · Tier 2 support" expanded={open()} onPress={() => open.update((v) => !v)} /> <If when={open()}> <Text class={`pl-[18px] ${TEXT_SIZE.small} text-muted-foreground`}>12 chats</Text> </If> </View> )}Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| Tab | Focus the heading or record row; with actions, the next Tab stops on the action |
| Space / Return | Toggle expanded and collapsed |
Accessibility
Section titled “Accessibility”- The role is button, and the state reads as expanded / collapsed.
- Disclosure’s screen reader name defaults to its heading; without accessibilityLabel, DisclosureRow reads the text in the row, so give a short screen reader name when the row holds a lot.
- Disabled items are not in the Tab order, and are 40% transparent.
- leading, suffix and trailing sit inside the toggle button, and screen readers read only its name; put a state that must be read (a failed tool) into accessibilityLabel.
- actions sit outside the button, each its own Tab stop and screen reader element; don’t put pressable controls in leading, suffix or trailing.
Do / Don’t
Section titled “Do / Don’t”Do
- Expand the most-used group by default
- Indent expanded content 18 to align with the heading text
- Expand only one record row at a time
- Give the collapsible headings in one place the same variant and chevron position
- Put actions on a group heading (Clear, New) in actions
Don’t
- Collapse the only content there is
- Use Disclosure for navigation (use the sidebar or tabs)
- Put buttons in a DisclosureRow (put them in the expanded details)
- Put buttons or segmented controls in suffix / trailing (they end up inside the toggle button)
Property descriptions follow the Chinese source comments.
Disclosure
Section titled “Disclosure”| Prop | Type | Default | Description |
|---|---|---|---|
title * |
string |
— | 分组标题,单行截断、悬停看全文 |
expanded * |
boolean |
— | |
onPress * |
() => void |
— | |
disabled |
boolean |
— | |
variant |
DisclosureVariant |
'default' |
外观,默认 default |
chevron |
'start' | 'end' |
— | 箭头在行首(访达的展开三角,默认)还是行尾(附加说明行、面板分区头) |
leading |
JSX.Element |
— | 标题前的图标或任意节点(图标 13 / 14,muted-foreground) |
suffix |
JSX.Element |
— | 紧跟标题的小字:条数、徽标 |
trailing |
JSX.Element |
— | 行尾右对齐的附加:状态图标、元信息文字;窄时先收缩它,在行尾箭头左边 |
actions |
JSX.Element |
— | 与标题同一行、在展开按钮之外的独立操作(清空、新建):点它不切换展开 |
accessibilityLabel |
string |
— | 读屏名;不给时读标题 |
tooltip |
string |
— | 悬停展开按钮时的提示(如「收起」/「展开」);标题文字截断时仍悬停看全文 |
testID |
string |
— | |
class |
string |
— | 根节点的布局类(高度、内边距、外边距、整行悬停底) |
* required
DisclosureRow
Section titled “DisclosureRow”| Prop | Type | Default | Description |
|---|---|---|---|
expanded * |
boolean |
— | |
onPress * |
() => void |
— | |
disabled |
boolean |
— | |
accessibilityLabel |
string |
— | 读屏名;不给时读屏念行内文字 |
testID |
string |
— | |
class |
string |
— | 根节点的布局类 |
children |
JSX.Element |
— | 行的内容(时间、标签、状态、摘要),由调用方排;展开后的详情放在行外 |
* required