Skip to content

feat: add expandDirection prop to List.Accordion/Group (#4852)#4853

Open
futurk wants to merge 4 commits intocallstack:mainfrom
futurk:feat/add-expand-direction
Open

feat: add expandDirection prop to List.Accordion/Group (#4852)#4853
futurk wants to merge 4 commits intocallstack:mainfrom
futurk:feat/add-expand-direction

Conversation

@futurk
Copy link

@futurk futurk commented Jan 24, 2026

Motivation

upward-expanding-lists are common on the web.

Related issue

#4852

Test plan

check out the last List.Section components of :
example/src/Examples/ListAccordionExample.tsx and example/src/Examples/ListAccordionGroupExample.tsx

@callstack-bot
Copy link

callstack-bot commented Jan 25, 2026

Hey @futurk, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@azizbecha
Copy link
Collaborator

Hey @futurk,
Thanks for your efforts, can you also add this to the documentation too ?
Notice: can we simplify this block of nested ternary operators by creating a simpler function to avoid excessive complexity.

Screen Shot 2026-02-02 at 23 40 25 PM

Example:

function getExpandedContent({
  isExpanded,
  children,
  left,
  theme,
}: {
  isExpanded: boolean;
  children: React.ReactNode;
  left: boolean;
  theme: Theme;
}) {
  if (!isExpanded) {
    return null;
  }

  return React.Children.map(children, (child) => {
    if (
      left &&
      React.isValidElement<ListChildProps>(child) &&
      !child.props.left &&
      !child.props.right
    ) {
      return React.cloneElement(child, {
        style: [
          theme.isV3 ? styles.childV3 : styles.child,
          child.props.style,
        ],
        theme,
      });
    }

    return child;
  });
}

Usage:

const expandedContent = getExpandedContent({
  isExpanded,
  children,
  left,
  theme,
});

@futurk
Copy link
Author

futurk commented Feb 6, 2026

Done. The default value of expandDirection is also documented now.

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.

3 participants