JGuang

Collapse

Collapse · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Collapse

A content area that can be collapsed/expanded.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

A content area that can be collapsed/expanded.

When to Use

  • Group and hide complex areas to keep pages tidy.
  • An accordion is a special type of accordion panel that only allows a single content area to expand.

Demos

Collapse

Props

NameDescriptionTypeDefault
accordionWhether to enable accordion modebooleanfalse
activeKeyThe key of the currently expanded panelaccordion mode: string | null <br/>non-accordion mode: string[]-
arrowIconCustom arrow icon. if you pass a ReactNode, antd-mobile will add a rotate animation for you.React.ReactNode | ((active: boolean) => React.ReactNode)-
defaultActiveKeyThe key of the expanded panel by defaultaccordion mode: string | null <br/>non-accordion mode: string[]-
onChangeTriggered when the panel is switchedaccordion mode: (activeKey: string | null) => void <br /> non-accordion mode: (activeKey: string[]) => void-

Collapse.Panel

Props

NameDescriptionTypeDefault
arrowIconCustom arrow iconReact.ReactNode | ((active: boolean) => React.ReactNode)-
destroyOnCloseDestroy dom when not visiblebooleanfalse
disabledWhether disabled or notbooleanfalse
forceRenderWhether to render the DOM structure when hiddenbooleanfalse
keyThe unique identifierstring-
onClickThe click event of title bar(event: React.MouseEvent<Element, MouseEvent>) => void-
titleThe content on the left side of the title barReactNode-