logoNamu Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
1.0.0
  • Components Overview
  • General
    • Button
    • FloatButtonNew
    • Icon
    • Typography
  • Layout
    • Divider
    • Grid
    • Layout
    • Space
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPickerNew
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCodeNew
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • TourNew
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • AppNew
    • ConfigProvider
When To Use
Examples
Collapse
Size
Accordion
Nested panel
Borderless
Custom Panel
No arrow
Extra node
Ghost Collapse
Collapsible
API
Collapse
Collapse.Panel
Design Token

Collapse

  • CarouselDescriptions

    Resources

    Namu Design Charts
    Namu Design Pro
    Namu Design Pro Components
    Namu Design Mobile
    Namu Design Mini
    Namu Design Landing-Landing Templates
    Scaffolds-Scaffold Market
    Umi-React Application Framework
    dumi-Component doc generator
    qiankun-Micro-Frontends Framework
    ahooks-React Hooks Library
    Ant Motion-Motion Solution
    China Mirror 🇨🇳

    Community

    Awesome Namu Design
    Medium
    Twitter
    yuqueNamu Design in YuQue
    Namu Design in Zhihu
    Experience Cloud Blog
    seeconfSEE Conf-Experience Tech Conference

    Help

    GitHub
    Change Log
    FAQ
    Bug Report
    Issues
    Discussions
    StackOverflow
    SegmentFault

    Ant XTechMore Products

    yuqueYuQue-Document Collaboration Platform
    AntVAntV-Data Visualization
    EggEgg-Enterprise Node.js Framework
    kitchenKitchen-Sketch Toolkit
    xtechAnt Financial Experience Tech
    Theme Editor
    Made with ❤ by
    Ant Group and Namu Design Community

    A content area which can be collapsed and expanded.

    When To Use

    • Can be used to group or hide complex regions to keep the page clean.
    • Accordion is a special kind of Collapse, which allows only one panel to be expanded at a time.
    // works when >= 5.6.0, recommended ✅
    const text = `
    A dog is a type of domesticated animal.
    Known for its loyalty and faithfulness,
    it can be found as a welcome guest in many households across the world.
    `;
    const items: CollapseProps['items'] = [
    {
    key: '1',
    label: 'This is panel header 1',
    children: <p>{text}</p>,
    },
    {
    key: '2',
    label: 'This is panel header 2',
    children: <p>{text}</p>,
    },
    {
    key: '3',
    label: 'This is panel header 3',
    children: <p>{text}</p>,
    },
    ];
    <Collapse items={items} defaultActiveKey={['1']} />;
    // works when <5.6.0 , deprecated when >=5.6.0 🙅🏻‍♀️
    <Collapse defaultActiveKey={['1']} onChange={onChange}>
    <Panel header="This is panel header 1" key="1">
    <p>{text}</p>
    </Panel>
    <Panel header="This is panel header 2" key="2">
    <p>{text}</p>
    </Panel>
    <Panel header="This is panel header 3" key="3">
    <p>{text}</p>
    </Panel>
    </Collapse>;

    Examples

    Collapse

    By default, any number of panels can be expanded at a time. The first panel is expanded in this example.

    expand codeexpand code
    Size

    Namu Design supports a default collapse size as well as a large and small size.

    If a large or small collapse is desired, set the size property to either large or small respectively. Omit the size property for a collapse with the default size.

    expand codeexpand code
    Accordion

    In accordion mode, only one panel can be expanded at a time.

    expand codeexpand code
    Nested panel

    Collapse is nested inside the Collapse.

    expand codeexpand code
    Borderless

    A borderless style of Collapse.

    expand codeexpand code
    Custom Panel

    Customize the background, border, margin styles and icon for each panel.

    expand codeexpand code
    No arrow

    You can hide the arrow icon by passing showArrow={false} to CollapsePanel component.

    expand codeexpand code
    Extra node

    Render extra element in the top-right corner of each panel.

    expand codeexpand code
    Ghost Collapse

    Making collapse's background to transparent.

    expand codeexpand code
    Collapsible

    Specify the trigger area of collapsible by collapsible.

    expand codeexpand code

    API

    Common props ref:Common props

    Collapse

    PropertyDescriptionTypeDefaultVersion
    accordionIf true, Collapse renders as Accordionbooleanfalse
    activeKeyKey of the active panelstring[] | string
    number[] | number
    No default value. In accordion mode, it's the key of the first panel
    borderedToggles rendering of the border around the collapse blockbooleantrue
    collapsibleSpecify whether the panels of children be collapsible or the trigger area of collapsibleheader | icon | disabled-4.9.0
    defaultActiveKeyKey of the initial active panelstring[] | string
    number[] | number
    -
    destroyInactivePanelDestroy Inactive Panelbooleanfalse
    expandIconAllow to customize collapse icon(panelProps) => ReactNode-
    expandIconPositionSet expand icon positionstart | end-4.21.0
    ghostMake the collapse borderless and its background transparentbooleanfalse4.4.0
    sizeSet the size of collapselarge | middle | smallmiddle5.2.0
    onChangeCallback function executed when active panel is changedfunction-
    itemscollapse items contentItemType-5.6.0

    Collapse.Panel

    >= 5.6.0 configure the panel by `items`.
    PropertyDescriptionTypeDefaultVersion
    collapsibleSpecify whether the panel be collapsible or the trigger area of collapsibleheader | icon | disabled-4.9.0 (icon: 4.24.0)
    extraThe extra element in the cornerReactNode-
    forceRenderForced render of content on panel, instead of lazy rendering after clicking on headerbooleanfalse
    headerTitle of the panelReactNode-
    keyUnique key identifying the panel from among its siblingsstring | number-
    showArrowIf false, panel will not show arrow icon. If false, collapsible can't be set as iconbooleantrue

    Design Token

    Global Token

    This is panel header 1

    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.

    This is panel header 2
    This is panel header 3
    Default Size
    This is default size panel header
    Small Size
    This is small size panel header
    Large Size
    This is large size panel header
    This is panel header 1
    This is panel header 2
    This is panel header 3
    This is panel header 1
    This is panel header 2
    This is panel header 3
    This is panel header 1

    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.

    This is panel header 2
    This is panel header 3
    This is panel header 1

    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.

    This is panel header 2
    This is panel header 3
    This is panel header with arrow icon

    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.

    This is panel header with no arrow icon
    This is panel header 1
    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
    This is panel header 2
    This is panel header 3

    Expand Icon Position:
    start
    This is panel header 1

    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.

    This is panel header 2
    This is panel header 3
    This panel can only be collapsed by clicking text

    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.

    This panel can only be collapsed by clicking icon

    A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.

    This panel can't be collapsed