Description
Summary
Allow customizing the expand/collapse indicator icon on TreeList rows. Today the indicator is hardcoded to a rotating chevronRight, so patterns like a file/folder tree — where an expandable node should show a closed-folder icon when collapsed and an open-folder icon when expanded — aren't expressible.
Motivation
- A folder tree is one of the most common TreeList use cases, and the folder-open / folder-closed icon swap is the expected visual language for it.
- More generally, teams want the expand affordance to match their domain (folders, categories, org nodes) rather than a generic chevron.
startContentalready lets you put an icon before the label, but it doesn't control the expand/collapse indicator itself, which is a separate, hardcoded element.
Current behavior
In TreeListItem.tsx the indicator is fixed:
const chevronIcon = (
<span {...stylex.props(styles.chevronSvg, isExpanded ? styles.chevronExpanded : styles.chevronCollapsed)}>
{getIcon('chevronRight')}
</span>
);There is no prop to override it, and the collapsed/expanded states are expressed only by rotating the same chevron.
Proposed API
Add a way to supply a custom indicator, ideally state-aware so collapsed vs. expanded can be distinct icons (not just a rotation). A render-prop keeps it flexible and avoids a rotation assumption:
<TreeList
renderExpandIcon={({ isExpanded, hasChildren, isDisabled }) =>
hasChildren
? (isExpanded ? <Icon icon="folderOpen" /> : <Icon icon="folder" />)
: <Icon icon="file" />
}
/>Open to a simpler shape if preferred (e.g. expandIcon / collapseIcon props). Key requirements:
- Distinguish collapsed vs expanded icons (folder-closed / folder-open), not just a rotated single icon.
- Optionally distinguish leaf nodes (no children) so a folder tree can render a file/leaf icon in the indicator slot.
- Default stays the current chevron — this is opt-in.
- Preserve the existing a11y wiring: the toggle button keeps
aria-expanded,aria-label, roving-tabindex behavior, anddata-tree-toggleregardless of the icon rendered inside it.
Notes
- Should the rotation animation be suppressed automatically when a custom state-aware icon is provided (so an open-folder icon isn't also rotated)? Probably yes.
- Per-item override vs. tree-level render prop — a tree-level
renderExpandIconcovers the folder case cleanly; per-item could come later if needed.
Environment
- Component:
TreeList(@astryxdesign/core),packages/core/src/TreeList/TreeListItem.tsx
Activity
Merge upstream/main (focus-visible CSS-var fix meta#4156) into meta#4131
Merge upstream/main into meta#4131 branch
fix(TreeList): size the indicator column 1rem so sm icons fill it (me…
fix(TreeList): never report a leaf as expanded to renderExpandIcon (m…
cixzhang commentedon Nov 20, 2026
Covered on
main: a theme'stree-disclosureindicator replaces the branch chevron with an open/closed mark (component:TreeListFR10), and leaf icons go in each row'sstartContent(FR3). #4228 has a short example. Thanks to @AKnassa for the request and the PR.