Skip to content

feat!: modernize List-related components to the latest MD3 specs - #5224

Open
jacekAtCK wants to merge 22 commits into
callstack:mainfrom
jacekAtCK:feat/modernize-list-md3
Open

jacekAtCK wants to merge 22 commits into
callstack:mainfrom
jacekAtCK:feat/modernize-list-md3

Conversation

@jacekAtCK

@jacekAtCK jacekAtCK commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Takes over #5143. Brings List.Item and List.Accordion in line with the MD3 list spec: tokens, spacing and typography, selected state, animated accordion, and leading and trailing slots on List.Item. left and right on List.Item are deprecated.

Related issue

Closes #4976
Part of #4930

Screenshots / Videos

List.Accordion on Android
list-accordion.mp4

Test plan

In the List example:

  1. Compare rows against the spec.
  2. Expand and collapse an accordion. Rows below move with it.
  3. A selected row uses the secondary container colors.

@Doberjohn Doberjohn assigned Doberjohn and jacekAtCK and unassigned Doberjohn Nov 16, 2026
@Doberjohn Doberjohn added this to the 6.0.0-beta.0 milestone Nov 16, 2026
@jacekAtCK jacekAtCK changed the title feat: modernize List-related components to the latest MD3 specs feat!: modernize List-related components to the latest MD3 specs Nov 16, 2026
@Doberjohn
Doberjohn self-requested a review November 17, 2026 18:52
@Doberjohn

Copy link
Copy Markdown
Collaborator

/review

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 3 new findings on cd9dfe1. The verdict and the full list are in the summary comment.

Comment thread src/components/List/ListAccordion.tsx Resolved
Comment thread src/components/List/ListAccordion.tsx Resolved
Comment thread src/components/List/ListItem.tsx Resolved
@apex-sentinel-staging

This comment has been minimized.

@Doberjohn Doberjohn left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Four things block the merge:

  1. Migration guide. As a breaking PR, it needs before and after entries under ### List in docs/6.x/docs/guides/migration.md:

    • List.Accordion: the title and icon no longer turn primary when expanded, the header is surface instead of background, the chevron rotates instead of switching to chevron-up, and the content animates and stays mounted until the collapse ends.
    • List.Item and List.Accordion: bodyLarge and bodyMedium typography instead of fontSize 16 and 14, MD3 heights (56, 72 and 88dp) and a 16dp trailing inset instead of 24dp.
    • List.Image with variant="video": a new vertical margin.

    For the squash I'd use: BREAKING CHANGE: List.Item and List.Accordion now use the MD3 list sizes, spacing and theme typography, and List.Accordion keeps its colors when expanded and animates its content.

  2. Selected colors. The spec tokens give #E8DEF8 and #4A4458 for the selected state, which are secondaryContainer and onSecondaryContainer, not the primary pair. Could tokens.ts use those? Better settled before 6.0.

  3. Button role. A pressable List.Item has no role, so screen readers don't announce it as a button. Could you set it before {...rest}, and move aria-selected there too? That also fixes the open thread about it being overwritten.

    focusRing="inward"
    role={onPress ? 'button' : undefined}
    aria-selected={selected}
    {...rest}

    The full test suite passes with this, with no snapshot changes.

  4. Deprecate left and right on List.Item. On the question from #5143: we'll keep both in 6.x and remove left and right in 7.0. Could you mark them @deprecated in the JSDoc, pointing to leading and trailing (no runtime warning), switch the usage examples in ListItem.tsx and ListSection.tsx to the slots, and add a line to the migration guide? List.Accordion keeps left and right for now.

Comment thread src/components/List/ListAccordion.tsx Resolved
opacity: contentProgress.value,
}));

const onContentLayout = (event: LayoutChangeEvent) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: setting state on every layout re-renders the outer accordion on every frame while a nested one animates. Keeping the height in a shared value would avoid that. Untested.

Comment thread src/components/List/ListItem.tsx Resolved
style,
styles.video,
{
marginVertical: ListTokens.threeLineVerticalPadding - verticalPadding,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: style comes first here, so callers can't override this margin. Put it last?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiya! I tried this, but it breaks the common left={(props) => <List.Image variant="video" style={props.style} />} pattern. props.style from left has marginLeft: 16, and marginVertical: 0 when the row has no description. With style last, these win over the video margins, so a one-line video row drops from 88 to 80 and thumbnail moves 16dp. I kept the order for now. Lemme know if you see a better way though

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@jacekAtCK
jacekAtCK requested a review from Doberjohn November 19, 2026 12:43
@jacekAtCK

Copy link
Copy Markdown
Collaborator Author

Four things block the merge:

1. **Migration guide.** As a breaking PR, it needs before and after entries under `### List` in `docs/6.x/docs/guides/migration.md`:
   
   * `List.Accordion`: the title and icon no longer turn `primary` when expanded, the header is `surface` instead of `background`, the chevron rotates instead of switching to `chevron-up`, and the content animates and stays mounted until the collapse ends.
   * `List.Item` and `List.Accordion`: `bodyLarge` and `bodyMedium` typography instead of `fontSize` 16 and 14, MD3 heights (56, 72 and 88dp) and a 16dp trailing inset instead of 24dp.
   * `List.Image` with `variant="video"`: a new vertical margin.
   
   For the squash I'd use: `BREAKING CHANGE: List.Item and List.Accordion now use the MD3 list sizes, spacing and theme typography, and List.Accordion keeps its colors when expanded and animates its content.`

2. **Selected colors.** The spec tokens give `#E8DEF8` and `#4A4458` for the selected state, which are `secondaryContainer` and `onSecondaryContainer`, not the primary pair. Could `tokens.ts` use those? Better settled before 6.0.

3. **Button role.** A pressable `List.Item` has no role, so screen readers don't announce it as a button. Could you set it before `{...rest}`, and move `aria-selected` there too? That also fixes the open thread about it being overwritten.
   focusRing="inward"
   role={onPress ? 'button' : undefined}
   aria-selected={selected}
   {...rest}
   The full test suite passes with this, with no snapshot changes.

4. **Deprecate `left` and `right` on `List.Item`.** On the question from [feat: modernize List-related components to the latest MD3 specs #5143](https://github.com/callstack/react-native-paper/pull/5143): we'll keep both in 6.x and remove `left` and `right` in 7.0. Could you mark them `@deprecated` in the JSDoc, pointing to `leading` and `trailing` (no runtime warning), switch the usage examples in `ListItem.tsx` and `ListSection.tsx` to the slots, and add a line to the migration guide? `List.Accordion` keeps `left` and `right` for now.

all four are fixed now.

@jacekAtCK

Copy link
Copy Markdown
Collaborator Author

/review

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 6e1aa5f. The verdict and the full list are in the summary comment.

Comment thread docs/6.x/docs/guides/migration.md Resolved
@apex-sentinel-staging

This comment has been minimized.

Comment on lines +53 to +59
right={(props) => (
<Checkbox
status="checked"
aria-label="Headline"
style={props.style}
/>
)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the left and right props are going to be deprecated, please update examples to use the latest API

Comment on lines +268 to +273
const leadingColor = selected
? theme.colors[ListTokens.selectedContentColor]
: theme.colors[ListTokens.leadingIconColor];
const trailingColor = selected
? theme.colors[ListTokens.selectedContentColor]
: theme.colors[ListTokens.trailingIconColor];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These four selected ? selectedContentColor : <token> ternaries (also 201-203, 255-257) repeat what getAccordionColors in utils.ts does for List.Accordion. The only difference is the trailing icon token (trailingIconColor vs expandTrailingIconColor). Could we turn getAccordionColors into a shared helper and use it in both List.Item and List.Accordion, so the selected-state rule lives in one place?

export const getListColors = ({ theme, selected }: { theme: InternalTheme; selected?: boolean }) => {
  const pick = (role: ColorRole) =>
    theme.colors[selected ? ListTokens.selectedContentColor : role];

  return {
    titleColor: pick(ListTokens.headlineColor),
    descriptionColor: pick(ListTokens.supportingTextColor),
    leadingIconColor: pick(ListTokens.leadingIconColor),
    trailingIconColor: pick(ListTokens.trailingIconColor),
    expandIconColor: pick(ListTokens.expandTrailingIconColor),
  };
};

Nit: the container* styles and the rowContext useMemo are also the same in ListItem and ListAccordion. They could be shared too.

Comment on lines +43 to +47
export const getLeftStyles = (alignToTop: boolean, description: Description) =>
getAccessoryStyles(alignToTop, description);

if (!description) {
return {
...styles.iconMarginRight,
...styles.marginVerticalNone,
...stylesV3,
};
}

return {
...styles.iconMarginRight,
...stylesV3,
};
};
export const getRightStyles = (alignToTop: boolean, description: Description) =>
getAccessoryStyles(alignToTop, description);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLeftStyles and getRightStyles are now identical wrappers around getAccessoryStyles. They aren't part of the public API, and only ListUtils.test.tsx uses both. Could we export getAccessoryStyles directly and drop the wrappers?

Comment thread src/components/List/ListAccordion.tsx Resolved
Comment on lines +198 to +204
const backgroundColor = selected
? theme.colors[ListTokens.selectedContainerColor]
: undefined;
const titleColor = selected
? theme.colors[ListTokens.selectedContentColor]
: theme.colors[ListTokens.headlineColor];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled has no visual state. It reaches TouchableRipple through rest, so the row stops responding to presses but looks exactly like an enabled one. The MD3 tokens (md.comp.list.list-item.disabled.*) set the label, supporting text and leading/trailing icons to onSurface at 0.38 opacity. For a selected row, selected.disabled.container is onSurface at 0.38 opacity as well, not secondaryContainer.

I checked it on the iOS simulator with <List.Item disabled /> and <List.Item selected disabled />. Both render like their enabled counterparts. List.Accordion has no disabled prop at all.

Could we add disabled* entries to tokens.ts, the same way Checkbox and Switch do, and apply them here?

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 70280c9

Since the review of c3d3ecf: 1 new · 0 still open · 0 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
src/components/List/ListItem.tsx:319 🆕 aria-selected is not announced on role="button"; IconButton uses aria-pressed/aria-checked instead
Not in the reviewers' prompt (4 files)
  • src/components/__tests__/__snapshots__/ListAccordion.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/ListImage.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/ListItem.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/ListSection.test.tsx.snap: generated or a lockfile, so its lines were left out

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (9029fbcd5df0).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 70280c9. The verdict and the full list are in the summary comment.

Comment on lines +319 to +320
role={onPress ? 'button' : undefined}
aria-selected={selected}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆕 🟡 Minor · aria-selected is not announced on role="button"; IconButton uses aria-pressed/aria-checked instead

Setting role="button" together with aria-selected on List.Item or List.Accordion is an invalid ARIA combination—on web the browser drops the state and selection is never announced, making the migration guide's claim "Screen readers announce it as selected" false there. IconButton already uses aria-pressed on web and aria-checked on native for this reason; DrawerItem and BottomNavigation pair role="button" with aria-selected too.

Suggested change

Emit aria-pressed on web and aria-checked on native for selected rows (keyed off selected !== undefined), or document why the button role is excluded here. Re-check the migration-guide sentence against the role actually rendered, and update DrawerItem/BottomNavigation together if the rule is applied repo-wide.

Details

persona: senior-developer, react-native-paper

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: modernize List related components to the latest MD3 specs

6 participants