logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
YouMindTRACTIANLobeHubCodeRabbit
6.5.0
  • Components Overview
  • Changelog
    v6.5.0
  • General
    • Button
    • FloatButton
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
    • 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
      DEPRECATED
    • Popover
    • QRCode
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • App
    • BorderBeam
      6.4.0
    • ConfigProvider
    • Util
When To Use
Examples
Collapse
Size
Accordion
Nested panel
Borderless
Custom Panel
No arrow
Extra node
Ghost Collapse
Collapsible
Custom semantic dom styling
API
Collapse
ItemType
Collapse.Panel
Semantic DOM
Design Token

Collapse

A content area which can be collapsed and expanded.
Importimport { Collapse } from 'antd';
GitHub
components/collapseIssueOpen issues
Docs
Edit this pageLLMs.md
CarouselDescriptions

Resources

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

Community

Awesome Ant Design
Medium
X
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
For Agents
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

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.

Examples

API

Common props ref:Common props

Collapse

PropertyDescriptionTypeDefaultVersionGlobal Config
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×
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-6.0.0
collapsibleSpecify how to trigger Collapse. Either by clicking icon or by clicking any area in header or disable collapse functionality itselfheader | icon | disabled-4.9.0×
defaultActiveKeyKey of the initial active panelstring[] | string
number[] | number
-×
destroyInactivePanelDestroy Inactive Panelbooleanfalse×
destroyOnHiddenDestroy Inactive Panelbooleanfalse5.25.0×
expandIconCustomize the collapse expand icon(panelProps) => ReactNode-5.15.0
expandIconPlacementSet expand icon placementstart | endstart-×
expandIconPositionSet expand icon position, Please use expandIconPlacement insteadstart | end-4.21.0×
ghostMake the collapse borderless and its background transparentbooleanfalse4.4.0×
sizeSet the size of collapselarge | medium | smallmedium5.2.0×
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-6.0.0
onChangeCallback function executed when active panel is changedfunction-×
itemscollapse items contentItemType-5.6.0×

ItemType

PropertyDescriptionTypeDefaultVersion
classNamesSemantic structure classNameRecord<header | body, string>-5.21.0
collapsibleSpecify whether the panel be collapsible or the trigger area of collapsibleheader | icon | disabled-
childrenBody area contentReactNode-
extraThe extra element in the cornerReactNode-
forceRenderForced render of content on panel, instead of lazy rendering after clicking on headerbooleanfalse
keyUnique key identifying the panel from among its siblingsstring | number-
labelTitle of the panelReactNode--
showArrowIf false, panel will not show arrow icon. If false, collapsible can't be set as iconbooleantrue
stylesSemantic DOM styleRecord<header | body, CSSProperties>-5.21.0

Collapse.Panel

Deprecated

When using version >= 5.6.0, we prefer to configuring 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

Semantic DOM

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
borderlessContentBgBackground of content in borderless stylestringtransparent
borderlessContentPaddingPadding of content in borderless stylePadding<string | number> | undefined4px 16px 16px
contentBgBackground of contentstring#ffffff
contentPaddingPadding of contentPadding<string | number> | undefined16px 16px
contentPaddingLGPadding of large contentPadding<string | number> | undefined24
contentPaddingSMPadding of small contentPadding<string | number> | undefined12
headerBgBackground of headerstringrgba(0,0,0,0.02)
headerPaddingPadding of headerPadding<string | number> | undefined12px 16px
headerPaddingLGPadding of large headerPadding<string | number> | undefined16px 24px 16px 16px
headerPaddingSMPadding of small headerPadding<string | number> | undefined8px 12px 8px 8px
Global TokenHow to use?
Token NameDescriptionTypeDefault Value
colorBorderDefault border color, used to separate different elements, such as: form separator, card separator, etc.string#d9d9d9
colorPrimaryBorderThe stroke color under the main color gradient, used on the stroke of components such as Slider.string#91caff
colorTextDefault text color which comply with W3C standards, and this color is also the darkest neutral color.stringrgba(0,0,0,0.88)
colorTextDisabledControl the color of text in disabled state.stringrgba(0,0,0,0.25)
colorTextHeadingControl the font color of heading.stringrgba(0,0,0,0.88)
borderRadiusLGLG size border radius, used in some large border radius components, such as Card, Modal and other components.number8
fontFamilyThe font family of Ant Design prioritizes the default interface font of the system, and provides a set of alternative font libraries that are suitable for screen display to maintain the readability and readability of the font under different platforms and browsers, reflecting the friendly, stable and professional characteristics.string-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSizeThe most widely used font size in the design system, from which the text gradient will be derived.number14
fontSizeIconControl the font size of operation icon in Select, Cascader, etc. Normally same as fontSizeSM.number12
fontSizeLGLarge font sizenumber16
lineHeightLine height of text.number1.5714285714285714
lineHeightLGLine height of large text.number1.5
lineTypeBorder style of base componentsstringsolid
lineWidthBorder width of base componentsnumber1
lineWidthFocusControl the width of the line when the component is in focus state.number3
marginSMControl the margin of an element, with a medium-small size.number12
motionDurationMidMotion speed, medium speed. Used for medium element animation interaction.string0.2s
motionDurationSlowMotion speed, slow speed. Used for large element animation interaction.string0.3s
motionEaseInOutPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.645, 0.045, 0.355, 1)External Link Icon
paddingControl the padding of the element.number16
paddingLGControl the large padding of the element.number24
paddingSMControl the small padding of the element.number12
paddingXSControl the extra small padding of the element.number8
Collapse

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Size

Ant 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 medium size.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Accordion

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Nested panel

Collapse is nested inside the Collapse.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Borderless

A borderless style of Collapse.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom Panel

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
No arrow

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Extra node

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Ghost Collapse

Making collapse's background to transparent.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Collapsible

Specify the trigger area of collapsible by collapsible.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom semantic dom styling

You can customize the semantic dom style of Collapse by passing objects/functions through classNames and styles.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
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
Medium Size
This is medium 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 Placement:
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 be collapsed by clicking text or 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 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
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
This is panel header 2

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 3
This is panel header

This is panel body

  • root
    6.0.0
    Root element with border, border-radius, background color and container styles that control the overall layout and appearance of collapse panels
  • header
    5.21.0
    Header element with flex layout, padding, color, line-height, cursor style, transition animations and other interactive styles for panel headers
  • icon
    6.0.0
    Icon element with font size, transition animations, rotation transforms and other styles and animations for expand/collapse arrows
  • title
    6.0.0
    Title element with flex auto layout and margin styles for title text layout and typography
  • body
    5.21.0
    Body element with padding, color, background color and other styles for panel content area display