Use a native Disclosure Triangle for expandable rows: NSOutlineView for an outline hierarchy or SwiftUI DisclosureGroup for a standalone section. The small indicator must rotate between collapsed and expanded states while the row's children appear directly beneath it.
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my macOS disclosure triangle (NSButton .disclosure bezel, SwiftUI DisclosureGroup). Rule out: the isExpanded binding not actually driving the revealed content; several groups sharing one binding so they all toggle together; the triangle animating the wrong direction because state and rotation are set separately; baseline misalignment between the triangle and its label. The symptom:
# Disclosure Triangle · 披露三角
UI reference — https://K3tty5555.github.io/LearnUI_PM/macos/disclosure-triangle/
**The small rotating control that reveals or hides nested content**
那个会旋转的小控件,用来显示或隐藏嵌套内容
**Also called / 也叫:** disclosure control, outline disclosure button, expand-collapse triangle / 披露控件、大纲披露按钮、展开/折叠三角
## Anatomy — every part, named / 解剖
1. **Disclosure indicator · 披露指示器** (`NSButton.BezelStyle.disclosure`)
“The tiny triangle beside the row” is the disclosure indicator.
「行旁边那个小三角」就是披露指示器。
Prompt fragment: a native disclosure indicator using NSButton.BezelStyle.disclosure beside the expandable label
2. **Collapsed state · 折叠状态** (`DisclosureGroup.isExpanded`)
“The arrow pointing sideways before it opens” is the collapsed state.
「打开前朝侧面的箭头」就是折叠状态。
Prompt fragment: the collapsed DisclosureGroup.isExpanded = false state, with the indicator pointing sideways and children hidden
3. **Expanded state · 展开状态** (`DisclosureGroup.isExpanded`)
“The arrow rotated down after it opens” is the expanded state.
「打开后转向下方的箭头」就是展开状态。
Prompt fragment: the expanded DisclosureGroup.isExpanded = true state, with the disclosure indicator pointing down above the revealed children
## Prompt / 提示词
Use a native Disclosure Triangle for expandable rows: NSOutlineView for an outline hierarchy or SwiftUI DisclosureGroup for a standalone section. The small indicator must rotate between collapsed and expanded states while the row's children appear directly beneath it.
可展开的行用原生披露三角:大纲层级用 NSOutlineView,独立区块用 SwiftUI DisclosureGroup。小指示器必须在折叠和展开状态之间旋转,同时该行的子级直接出现在它下方。
## Debug prompt / 调试提示词
Debug my macOS disclosure triangle (NSButton .disclosure bezel, SwiftUI DisclosureGroup). Rule out: the isExpanded binding not actually driving the revealed content; several groups sharing one binding so they all toggle together; the triangle animating the wrong direction because state and rotation are set separately; baseline misalignment between the triangle and its label. The symptom:
调试我的 macOS 披露三角(NSButton .disclosure bezel、SwiftUI DisclosureGroup)。排除以下可能:isExpanded 绑定没有真正驱动显示的内容;多个 DisclosureGroup 共用一个绑定,结果一起开合;状态和旋转分开设置,三角动画方向错了;三角和标签基线没对齐。症状是:
## In code / 代码里叫什么
- **AppKit** `NSOutlineView`
- **SwiftUI** `DisclosureGroup`
- **AppKit** `NSButton.BezelStyle.disclosure` — a standalone disclosure button style / 一种独立的披露按钮样式