# 折叠面板

- 页面: https://jiguang132.com/zh/resources/material-ui/docs/accordion
- 资源: Material UI (https://jiguang132.com/zh/resources/material-ui.md)
- 全部指南: https://jiguang132.com/zh/resources/material-ui/docs.md

在当前页面展开和收起相关详情。

本指南覆盖默认 Emotion 环境的 Material UI Core；扩展包与额外示例按清单单独标注。

## 使用场景与业务边界

展开是界面状态，不代表已加载后端数据；保留标题层级与无障碍关联。

## 原生组成与范围

`Accordion`, `AccordionActions`, `AccordionDetails`, `AccordionSummary`

保持 Material UI 原生组合与类型，不替换为 JGuang／Base UI／Radix 同名 API。示例条目不是额外组件。

## 原生安装与初始化

```bash
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1
```

采用原生 npm 包与 Emotion，不提供虚构的 JGuang UI Registry 地址。将示例放在原生 ThemeProvider 内，按项目选择 CssBaseline 或 ScopedCssBaseline。先检查 React、现有 Provider、锁文件与 SSR 配置；不要覆盖用户文件或忽略 peer 冲突。本批实际验收 React 19.2.8；React 18 及以下须匹配 react-is。完整初始化规则见随附的双语 setup 文档。

## 关键原生参数

仅解释本指南选出的关键参数，不是平铺的通用 API。原生继承来源、slot 结构、可空值与泛型仍按固定源码保留。

| 所属组件.属性 | 用途说明 | 声明来源 |
| --- | --- | --- |
| `Accordion.expanded` | 受控 Accordion 展开状态，在 onChange 中更新。 | `Accordion` |
| `Accordion.onChange` | 所属控件的原生回调，保留其准确事件／数值／可空签名。 | `Accordion` |
| `Accordion.defaultExpanded` | 非受控 Accordion 的初始展开值，不是持续受控值。 | `Accordion` |
| `Accordion.disabled` | 原生禁用交互状态，不是权限校验。 | `Accordion` |

## 可运行原生示例

下列机器键只选择示例入口，不会作为通用 variant 属性传入每个组件。原生示例 JSX 与数据保持上游原文；JGuang 编写的验收示例明确标注。

- 基础介绍 · `AccordionUsage` · 上游原生示例
- 展开图标 · `AccordionExpandIcon` · 上游原生示例
- 默认展开 · `AccordionExpandDefault` · 上游原生示例
- 过渡动画 · `AccordionTransition` · 上游原生示例
- 禁用项 · `DisabledAccordion` · 上游原生示例
- 受控折叠面板 · `ControlledAccordions` · 上游原生示例
- 同时仅展开一个面板 · `CustomizedAccordions` · 上游原生示例

## 真实使用示例

固定版本的未修改原生示例；复制时同时保留所需的局部辅助文件。

```tsx
import * as React from 'react';
import Accordion from '@mui/material/Accordion';
import AccordionActions from '@mui/material/AccordionActions';
import AccordionSummary from '@mui/material/AccordionSummary';
import AccordionDetails from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import Button from '@mui/material/Button';

export default function AccordionUsage() {
  const id = React.useId();
  return (
    <div>
      <Accordion>
        <AccordionSummary
          expandIcon={<ExpandMoreIcon />}
          aria-controls={`${id}-panel1-content`}
          id={`${id}-panel1-header`}
        >
          <Typography component="span">Accordion 1</Typography>
        </AccordionSummary>
        <AccordionDetails>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
          malesuada lacus ex, sit amet blandit leo lobortis eget.
        </AccordionDetails>
      </Accordion>
      <Accordion>
        <AccordionSummary
          expandIcon={<ExpandMoreIcon />}
          aria-controls={`${id}-panel2-content`}
          id={`${id}-panel2-header`}
        >
          <Typography component="span">Accordion 2</Typography>
        </AccordionSummary>
        <AccordionDetails>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
          malesuada lacus ex, sit amet blandit leo lobortis eget.
        </AccordionDetails>
      </Accordion>
      <Accordion defaultExpanded>
        <AccordionSummary
          expandIcon={<ExpandMoreIcon />}
          aria-controls={`${id}-panel3-content`}
          id={`${id}-panel3-header`}
        >
          <Typography component="span">Accordion Actions</Typography>
        </AccordionSummary>
        <AccordionDetails>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
          malesuada lacus ex, sit amet blandit leo lobortis eget.
        </AccordionDetails>
        <AccordionActions>
          <Button>Cancel</Button>
          <Button>Agree</Button>
        </AccordionActions>
      </Accordion>
    </div>
  );
}

```

## 示例依赖边界

`react`, `@mui/material/Accordion`, `@mui/material/AccordionActions`, `@mui/material/AccordionSummary`, `@mui/material/AccordionDetails`, `@mui/material/Typography`, `@mui/icons-material/ExpandMore`, `@mui/material/Button`, `@mui/icons-material/ArrowDownward`, `@mui/icons-material/ArrowDropDown`, `@mui/material/Fade`, `@mui/material/styles`, `@mui/icons-material/ArrowForwardIosSharp`

直接导入 Icons／System／Utils 的示例需要匹配 9.4.0 包。局部数据与辅助文件属于示例闭包，不是额外组件。远程图片和模拟操作不提供后端。

## 固定上游 API 元数据参考

以下表格保留上游元数据，不是重新推断的通用类型体系。条件泛型、继承属性与回调细节以以下源码声明为准。主题默认配置可能覆盖元数据默认值。

### Accordion

```tsx
import Accordion from '@mui/material/Accordion';
import { Accordion } from '@mui/material';
```

原生继承: `Paper`. 父级与 DOM 属性未被伪造为本组件新属性。

| 属性 | 必需 | 上游元数据类型／约束 | 元数据默认值 |
| --- | --- | --- | --- |
| `children` | 是 | `node` | — |
| `classes` | 否 | `object` | — |
| `defaultExpanded` | 否 | `bool` | `false` |
| `disabled` | 否 | `bool` | `false` |
| `disableGutters` | 否 | `bool` | `false` |
| `expanded` | 否 | `bool` | — |
| `onChange` | 否 | `func` | — |
| `slotProps` | 否 | `{ heading?: func \| object, region?: func \| object, root?: func \| object, transition?: func \| object }` | `{}` |
| `slots` | 否 | `{ heading?: elementType, region?: elementType, root?: elementType, transition?: elementType }` | `{}` |
| `sx` | 否 | `Array<func \| object \| bool> \| func \| object` | — |



### AccordionActions

```tsx
import AccordionActions from '@mui/material/AccordionActions';
import { AccordionActions } from '@mui/material';
```

| 属性 | 必需 | 上游元数据类型／约束 | 元数据默认值 |
| --- | --- | --- | --- |
| `children` | 否 | `node` | — |
| `classes` | 否 | `object` | — |
| `disableSpacing` | 否 | `bool` | `false` |
| `sx` | 否 | `Array<func \| object \| bool> \| func \| object` | — |



### AccordionDetails

```tsx
import AccordionDetails from '@mui/material/AccordionDetails';
import { AccordionDetails } from '@mui/material';
```

| 属性 | 必需 | 上游元数据类型／约束 | 元数据默认值 |
| --- | --- | --- | --- |
| `children` | 否 | `node` | — |
| `classes` | 否 | `object` | — |
| `sx` | 否 | `Array<func \| object \| bool> \| func \| object` | — |



### AccordionSummary

```tsx
import AccordionSummary from '@mui/material/AccordionSummary';
import { AccordionSummary } from '@mui/material';
```

原生继承: `ButtonBase`. 父级与 DOM 属性未被伪造为本组件新属性。

| 属性 | 必需 | 上游元数据类型／约束 | 元数据默认值 |
| --- | --- | --- | --- |
| `children` | 否 | `node` | — |
| `classes` | 否 | `object` | — |
| `expandIcon` | 否 | `node` | — |
| `focusVisibleClassName` | 否 | `string` | — |
| `slotProps` | 否 | `{ content?: func \| object, expandIconWrapper?: func \| object, root?: func \| object }` | `{}` |
| `slots` | 否 | `{ content?: elementType, expandIconWrapper?: elementType, root?: elementType }` | `{}` |
| `sx` | 否 | `Array<func \| object \| bool> \| func \| object` | — |


## 原生源码声明

声明与 import 从固定源码提取，不平铺联合类型或外部继承。英文注释／类型属于原始源码参考，不代表上游正文已全文翻译。共享类型仍位于原生包中。

### vendor/src/Accordion/Accordion.d.ts

```ts
import * as React from 'react';

import { SxProps } from '@mui/system';

import { Theme } from '../styles';

import { TransitionProps } from '../transitions/types';

import { AccordionClasses } from './accordionClasses';

import { OverridableComponent, OverrideProps } from '../OverridableComponent';

import { ExtendPaperTypeMap, PaperProps } from '../Paper/Paper';

import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from '../utils/types';

export interface AccordionSlots {
  /**
   * The component that renders the root.
   * @default Paper
   */
  root: React.ElementType;
  /**
   * The component that renders the heading.
   * @default 'h3'
   */
  heading: React.ElementType;
  /**
   * The component that renders the transition.
   * [Follow this guide](/material-ui/transitions/#transition-slots) to learn more about the requirements for this component.
   * @default Collapse
   */
  transition: React.ElementType;
  /**
   * The component that renders the region.
   * @default 'div'
   */
  region: React.ElementType;
}

export interface AccordionRootSlotPropsOverrides {}

export interface AccordionHeadingSlotPropsOverrides {}

export interface AccordionTransitionSlotPropsOverrides {}

export interface AccordionRegionSlotPropsOverrides {}

export type AccordionSlotsAndSlotProps = CreateSlotsAndSlotProps<
  AccordionSlots,
  {
    /**
     * Props forwarded to the root slot.
     * By default, the available props are based on the Paper element.
     */
    root: SlotProps<
      React.ElementType<PaperProps>,
      AccordionRootSlotPropsOverrides,
      AccordionOwnerState
    >;
    /**
     * Props forwarded to the heading slot.
     * By default, the available props are based on the h3 element.
     */
    heading: SlotProps<'h3', AccordionHeadingSlotPropsOverrides, AccordionOwnerState>;
    /**
     * Props forwarded to the transition slot.
     * By default, the available props are based on the [Collapse](https://mui.com/material-ui/api/collapse/#props) component.
     */
    transition: SlotComponentProps<
      React.ElementType<TransitionProps>,
      TransitionProps & AccordionTransitionSlotPropsOverrides,
      AccordionOwnerState
    >;
    /**
     * Props forwarded to the region slot.
     * By default, the available props are based on the div element.
     */
    region: SlotProps<'div', AccordionRegionSlotPropsOverrides, AccordionOwnerState>;
  }
>;

export interface AccordionOwnProps {
  /**
   * The content of the component.
   */
  children: NonNullable<React.ReactNode>;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<AccordionClasses> | undefined;
  /**
   * If `true`, expands the accordion by default.
   * @default false
   */
  defaultExpanded?: boolean | undefined;
  /**
   * If `true`, the component is disabled.
   * @default false
   */
  disabled?: boolean | undefined;
  /**
   * If `true`, it removes the margin between two expanded accordion items and prevents the increased height when expanded.
   * @default false
   */
  disableGutters?: boolean | undefined;
  /**
   * If `true`, expands the accordion, otherwise collapses it.
   * Setting this prop enables control over the accordion.
   */
  expanded?: boolean | undefined;
  /**
   * Callback fired when the expand/collapse state is changed.
   *
   * @param {React.SyntheticEvent} event The event source of the callback. **Warning**: This is a generic event not a change event.
   * @param {boolean} expanded The `expanded` state of the accordion.
   */
  onChange?: ((event: React.SyntheticEvent, expanded: boolean) => void) | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
}

export type AccordionTypeMap<
  AdditionalProps = {},
  RootComponent extends React.ElementType = 'div',
> = ExtendPaperTypeMap<
  {
    props: AdditionalProps & AccordionOwnProps & AccordionSlotsAndSlotProps;
    defaultComponent: RootComponent;
  },
  'onChange' | 'classes'
>;

declare const Accordion: OverridableComponent<AccordionTypeMap>;

export type AccordionProps<
  RootComponent extends React.ElementType = AccordionTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<AccordionTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
  component?: React.ElementType | undefined;
};

export interface AccordionOwnerState extends AccordionProps {}
```

### vendor/src/AccordionActions/AccordionActions.d.ts

```ts
import * as React from 'react';

import { SxProps } from '@mui/system';

import { Theme } from '../styles';

import { InternalStandardProps as StandardProps } from '../internal';

import { AccordionActionsClasses } from './accordionActionsClasses';

export interface AccordionActionsProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
  /**
   * The content of the component.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<AccordionActionsClasses> | undefined;
  /**
   * If `true`, the actions do not have additional margin.
   * @default false
   */
  disableSpacing?: boolean | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
}

export default function AccordionActions(props: AccordionActionsProps): React.JSX.Element;
```

### vendor/src/AccordionDetails/AccordionDetails.d.ts

```ts
import * as React from 'react';

import { SxProps } from '@mui/system';

import { Theme } from '../styles';

import { InternalStandardProps as StandardProps } from '../internal';

import { AccordionDetailsClasses } from './accordionDetailsClasses';

export interface AccordionDetailsProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
  /**
   * The content of the component.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<AccordionDetailsClasses> | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
}

export default function AccordionDetails(props: AccordionDetailsProps): React.JSX.Element;
```

### vendor/src/AccordionSummary/AccordionSummary.d.ts

```ts
import * as React from 'react';

import { SxProps } from '@mui/system';

import { ButtonBaseProps, ExtendButtonBase, ExtendButtonBaseTypeMap } from '../ButtonBase';

import { OverrideProps } from '../OverridableComponent';

import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';

import { Theme } from '../styles';

import { AccordionSummaryClasses } from './accordionSummaryClasses';

export interface AccordionSummarySlots {
  /**
   * The component that renders the root slot.
   * @default ButtonBase
   */
  root: React.ElementType;
  /**
   * The component that renders the content slot.
   * @default div
   */
  content: React.ElementType;
  /**
   * The component that renders the expand icon wrapper slot.
   * @default div
   */
  expandIconWrapper: React.ElementType;
}

export interface AccordionSummaryRootSlotPropsOverrides {}

export interface AccordionSummaryContentSlotPropsOverrides {}

export interface AccordionSummaryExpandIconWrapperSlotPropsOverrides {}

export type AccordionSummarySlotsAndSlotProps = CreateSlotsAndSlotProps<
  AccordionSummarySlots,
  {
    /**
     * Props forwarded to the root slot.
     * By default, the available props are based on the [ButtonBase](https://mui.com/material-ui/api/button-base/#props) component.
     */
    root: SlotProps<
      React.ElementType<ButtonBaseProps>,
      AccordionSummaryRootSlotPropsOverrides,
      AccordionSummaryOwnerState
    >;
    /**
     * Props forwarded to the content slot.
     * By default, the available props are based on a div element.
     */
    content: SlotProps<
      'div',
      AccordionSummaryContentSlotPropsOverrides,
      AccordionSummaryOwnerState
    >;
    /**
     * Props forwarded to the expand icon wrapper slot.
     * By default, the available props are based on a div element.
     */
    expandIconWrapper: SlotProps<
      'div',
      AccordionSummaryExpandIconWrapperSlotPropsOverrides,
      AccordionSummaryOwnerState
    >;
  }
>;

export interface AccordionSummaryOwnProps extends AccordionSummarySlotsAndSlotProps {
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<AccordionSummaryClasses> | undefined;
  /**
   * The icon to display as the expand indicator.
   */
  expandIcon?: React.ReactNode;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
}

export type AccordionSummaryTypeMap<
  AdditionalProps = {},
  RootComponent extends React.ElementType = 'div',
> = ExtendButtonBaseTypeMap<{
  props: AdditionalProps & AccordionSummaryOwnProps;
  defaultComponent: RootComponent;
}>;

export interface AccordionSummaryOwnerState extends Omit<
  AccordionSummaryProps,
  'slots' | 'slotProps'
> {}

declare const AccordionSummary: ExtendButtonBase<AccordionSummaryTypeMap>;

export type AccordionSummaryProps<
  RootComponent extends React.ElementType = AccordionSummaryTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<AccordionSummaryTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
  component?: React.ElementType | undefined;
};
```

## 安装后验收

执行严格类型检查、生产构建和实际交互。检查键盘标签／焦点、原生支持的禁用／错误／只读语义、深浅色、窄屏和减少动画。按真实宿主数据检查回调，不把复制提示词当作安装完成。初始化工具还需检查服务端 HTML 与无告警水合。

## 来源与许可

https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e

MIT · @mui/material@9.4.0. 保留上游原始内容与许可证。上游完整原文保留于 vendor/docs，不标为全文中文化。

---

JGuang 全部资源索引: https://jiguang132.com/llms.txt
