卡片
组织相关内容、媒体和明确的主要或次要操作。
本指南覆盖默认 Emotion 环境的 Material UI Core;扩展包与额外示例按清单单独标注。
使用场景与业务边界
卡片不会获取数据;不要在一个可点击主操作中嵌套冲突的交互元素。
原生组成与范围
Card, CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Collapse, Paper
保持 Material UI 原生组合与类型,不替换为 JGuang/Base UI/Radix 同名 API。示例条目不是额外组件。
原生安装与初始化
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 结构、可空值与泛型仍按固定源码保留。
| 所属组件.属性 | 用途说明 | 声明来源 |
|---|---|---|
Card.variant | 所属组件的原生视觉枚举,不可替换为通用 variant 属性。 | Paper |
CardActionArea.component | 渲染的原生元素/组件类型,保留有效语义和 ref。 | ButtonBase |
CardMedia.component | 渲染的原生元素/组件类型,保留有效语义和 ref。 | CardMedia |
CardMedia.image | CardMedia 图片来源,使用正确媒体元素并提供降级。 | CardMedia |
可运行原生示例
下列机器键只选择示例入口,不会作为通用 variant 属性传入每个组件。原生示例 JSX 与数据保持上游原文;JGuang 编写的验收示例明确标注。
- 基础介绍 ·
BasicCard· 上游原生示例 - 描边卡片 ·
OutlinedCard· 上游原生示例 - 复合交互 ·
RecipeReviewCard· 上游原生示例 - 媒体内容 ·
MediaCard· 上游原生示例 - 媒体内容 ·
ImgMediaCard· 上游原生示例 - 主要操作 ·
ActionAreaCard· 上游原生示例 - 主要操作 ·
MultiActionAreaCard· 上游原生示例 - 界面控件 ·
MediaControlCard· 上游原生示例 - 激活状态样式 ·
SelectActionCard· 上游原生示例
真实使用示例
固定版本的未修改原生示例;复制时同时保留所需的局部辅助文件。
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
const bull = (
<Box
component="span"
sx={{ display: 'inline-block', mx: '2px', transform: 'scale(0.8)' }}
>
•
</Box>
);
export default function BasicCard() {
return (
<Card sx={{ minWidth: 275 }}>
<CardContent>
<Typography gutterBottom sx={{ color: 'text.secondary', fontSize: 14 }}>
Word of the Day
</Typography>
<Typography variant="h5" component="div">
be{bull}nev{bull}o{bull}lent
</Typography>
<Typography sx={{ color: 'text.secondary', mb: 1.5 }}>adjective</Typography>
<Typography variant="body2">
well meaning and kindly.
<br />
{'"a benevolent smile"'}
</Typography>
</CardContent>
<CardActions>
<Button size="small">Learn More</Button>
</CardActions>
</Card>
);
}
示例依赖边界
@mui/material/Box, @mui/material/Card, @mui/material/CardActions, @mui/material/CardContent, @mui/material/Button, @mui/material/Typography, react, @mui/material/styles, @mui/material/CardHeader, @mui/material/CardMedia, @mui/material/Collapse, @mui/material/Avatar, @mui/material/IconButton, @mui/material/colors, @mui/icons-material/Favorite, @mui/icons-material/Share, @mui/icons-material/ExpandMore, @mui/icons-material/MoreVert, @mui/material/CardActionArea, @mui/icons-material/SkipPrevious, @mui/icons-material/PlayArrow, @mui/icons-material/SkipNext
直接导入 Icons/System/Utils 的示例需要匹配 9.4.0 包。局部数据与辅助文件属于示例闭包,不是额外组件。远程图片和模拟操作不提供后端。
固定上游 API 元数据参考
以下表格保留上游元数据,不是重新推断的通用类型体系。条件泛型、继承属性与回调细节以以下源码声明为准。主题默认配置可能覆盖元数据默认值。
Card
import Card from '@mui/material/Card';
import { Card } from '@mui/material';
原生继承: Paper. 父级与 DOM 属性未被伪造为本组件新属性。
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
children | 否 | node | — |
classes | 否 | object | — |
raised | 否 | bool | false |
sx | 否 | Array<func | object | bool> | func | object | — |
CardActionArea
import CardActionArea from '@mui/material/CardActionArea';
import { CardActionArea } from '@mui/material';
原生继承: ButtonBase. 父级与 DOM 属性未被伪造为本组件新属性。
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
children | 否 | node | — |
classes | 否 | object | — |
slotProps | 否 | { focusHighlight?: func | object, root?: func | object } | {} |
slots | 否 | { focusHighlight?: elementType, root?: elementType } | {} |
sx | 否 | Array<func | object | bool> | func | object | — |
CardActions
import CardActions from '@mui/material/CardActions';
import { CardActions } from '@mui/material';
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
children | 否 | node | — |
classes | 否 | object | — |
disableSpacing | 否 | bool | false |
sx | 否 | Array<func | object | bool> | func | object | — |
CardContent
import CardContent from '@mui/material/CardContent';
import { CardContent } from '@mui/material';
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
children | 否 | node | — |
classes | 否 | object | — |
component | 否 | elementType | — |
sx | 否 | Array<func | object | bool> | func | object | — |
CardHeader
import CardHeader from '@mui/material/CardHeader';
import { CardHeader } from '@mui/material';
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
action | 否 | node | — |
avatar | 否 | node | — |
classes | 否 | object | — |
component | 否 | elementType | — |
disableTypography | 否 | bool | false |
slotProps | 否 | { action?: func | object, avatar?: func | object, content?: func | object, root?: func | object, subheader?: func | object, title?: func | object } | {} |
slots | 否 | { action?: elementType, avatar?: elementType, content?: elementType, root?: elementType, subheader?: elementType, title?: elementType } | {} |
subheader | 否 | node | — |
sx | 否 | Array<func | object | bool> | func | object | — |
title | 否 | node | — |
CardMedia
import CardMedia from '@mui/material/CardMedia';
import { CardMedia } from '@mui/material';
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
children | 否 | node | — |
classes | 否 | object | — |
component | 否 | elementType | — |
image | 否 | string | — |
src | 否 | string | — |
sx | 否 | Array<func | object | bool> | func | object | — |
Collapse
import Collapse from '@mui/material/Collapse';
import { Collapse } from '@mui/material';
原生继承: Transition. 父级与 DOM 属性未被伪造为本组件新属性。
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
addEndListener | 否 | func | — |
children | 否 | node | — |
classes | 否 | object | — |
collapsedSize | 否 | number | string | '0px' |
component | 否 | element type | — |
disablePrefersReducedMotion | 否 | bool | false |
easing | 否 | { enter?: string, exit?: string } | string | — |
in | 否 | bool | — |
orientation | 否 | 'horizontal' | 'vertical' | 'vertical' |
slotProps | 否 | { root?: func | object, wrapper?: func | object, wrapperInner?: func | object } | {} |
slots | 否 | { root?: elementType, wrapper?: elementType, wrapperInner?: elementType } | {} |
sx | 否 | Array<func | object | bool> | func | object | — |
timeout | 否 | 'auto' | number | { appear?: number, enter?: number, exit?: number } | duration.standard |
Paper
import Paper from '@mui/material/Paper';
import { Paper } from '@mui/material';
| 属性 | 必需 | 上游元数据类型/约束 | 元数据默认值 |
|---|---|---|---|
children | 否 | node | — |
classes | 否 | object | — |
component | 否 | elementType | — |
elevation | 否 | integer | 1 |
square | 否 | bool | false |
sx | 否 | Array<func | object | bool> | func | object | — |
variant | 否 | 'elevation' | 'outlined' | string | 'elevation' |
原生源码声明
声明与 import 从固定源码提取,不平铺联合类型或外部继承。英文注释/类型属于原始源码参考,不代表上游正文已全文翻译。共享类型仍位于原生包中。
vendor/src/Card/Card.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { DistributiveOmit } from '@mui/types';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { Theme } from '../styles';
import { PaperOwnProps } from '../Paper';
import { CardClasses } from './cardClasses';
export interface CardPropsColorOverrides {}
export interface CardOwnProps extends DistributiveOmit<PaperOwnProps, 'classes'> {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<CardClasses> | undefined;
/**
* If `true`, the card will use raised styling.
* @default false
*/
raised?: boolean | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface CardTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'div',
> {
props: AdditionalProps & CardOwnProps;
defaultComponent: RootComponent;
}
declare const Card: OverridableComponent<CardTypeMap>;
export type CardProps<
RootComponent extends React.ElementType = CardTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<CardTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
vendor/src/CardActionArea/CardActionArea.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { SlotProps, CreateSlotsAndSlotProps } from '../utils/types';
import { Theme } from '../styles';
import {
ButtonBaseProps,
ButtonBaseTypeMap,
ExtendButtonBase,
ExtendButtonBaseTypeMap,
} from '../ButtonBase';
import { OverrideProps } from '../OverridableComponent';
import { CardActionAreaClasses } from './cardActionAreaClasses';
export interface CardActionAreaSlots {
/**
* The component that renders the root.
* @default ButtonBase
*/
root: React.ElementType;
/**
* The component that renders the focusHighlight.
* @default span
*/
focusHighlight: React.ElementType;
}
export type CardActionAreaSlotsAndSlotProps = CreateSlotsAndSlotProps<
CardActionAreaSlots,
{
/**
* Props forwarded to the root slot.
* By default, the available props are based on the span element.
*/
root: SlotProps<React.ElementType<ButtonBaseProps>, {}, CardActionAreaOwnerState>;
/**
* Props forwarded to the focusHighlight slot.
* By default, the available props are based on the span element.
*/
focusHighlight: SlotProps<'span', {}, CardActionAreaOwnerState>;
}
>;
export interface CardActionAreaOwnerState extends Omit<
CardActionAreaProps,
'slots' | 'slotProps'
> {}
export interface CardActionAreaOwnProps {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<CardActionAreaClasses> | undefined;
focusVisibleClassName?: string | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export type CardActionAreaTypeMap<
AdditionalProps,
RootComponent extends React.ElementType,
> = ExtendButtonBaseTypeMap<{
props: AdditionalProps & CardActionAreaOwnProps & CardActionAreaSlotsAndSlotProps;
defaultComponent: RootComponent;
}>;
declare const CardActionArea: ExtendButtonBase<
CardActionAreaTypeMap<{}, ButtonBaseTypeMap['defaultComponent']>
>;
export type CardActionAreaProps<
RootComponent extends React.ElementType = ButtonBaseTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<CardActionAreaTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
vendor/src/CardActions/CardActions.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { InternalStandardProps as StandardProps } from '../internal';
import { CardActionsClasses } from './cardActionsClasses';
export interface CardActionsProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<CardActionsClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* If `true`, the actions do not have additional margin.
* @default false
*/
disableSpacing?: boolean | undefined;
}
export default function CardActions(props: CardActionsProps): React.JSX.Element;
vendor/src/CardContent/CardContent.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { Theme } from '../styles';
import { CardContentClasses } from './cardContentClasses';
export interface CardContentOwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<CardContentClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface CardContentTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'div',
> {
props: AdditionalProps & CardContentOwnProps;
defaultComponent: RootComponent;
}
declare const CardContent: OverridableComponent<CardContentTypeMap>;
export type CardContentProps<
RootComponent extends React.ElementType = CardContentTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<CardContentTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
vendor/src/CardHeader/CardHeader.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { TypographyProps } from '../Typography';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { Theme } from '../styles';
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
import { CardHeaderClasses } from './cardHeaderClasses';
export interface CardHeaderRootSlotPropsOverrides {}
export interface CardHeaderAvatarSlotPropsOverrides {}
export interface CardHeaderActionSlotPropsOverrides {}
export interface CardHeaderContentSlotPropsOverrides {}
export interface CardHeaderTitleSlotPropsOverrides {}
export interface CardHeaderSubheaderSlotPropsOverrides {}
export interface CardHeaderSlots {
/**
* The component that renders the root slot.
* @default 'div'
*/
root: React.ElementType;
/**
* The component that renders the avatar slot.
* @default 'div'
*/
avatar: React.ElementType;
/**
* The component that renders the action slot.
* @default 'div'
*/
action: React.ElementType;
/**
* The component that renders the content slot.
* @default 'div'
*/
content: React.ElementType;
/**
* The component that renders the title slot (as long as disableTypography is not `true`).
* [Follow this guide](https://mui.com/material-ui/api/typography/#props) to learn more about the requirements for this component.
* @default Typography
*/
title: React.ElementType;
/**
* The component that renders the subheader slot (as long as disableTypography is not `true`).
* [Follow this guide](https://mui.com/material-ui/api/typography/#props) to learn more about the requirements for this component.
* @default Typography
*/
subheader: React.ElementType;
}
export type CardHeaderSlotsAndSlotProps<
TitleTypographyComponent extends React.ElementType = React.ElementType<TypographyProps>,
SubheaderTypographyComponent extends React.ElementType = React.ElementType<TypographyProps>,
> = CreateSlotsAndSlotProps<
CardHeaderSlots,
{
/**
* Props forwarded to the root slot.
* By default, the available props are based on the div element.
*/
root: SlotProps<'div', CardHeaderRootSlotPropsOverrides, CardHeaderOwnerState>;
/**
* Props forwarded to the avatar slot.
* By default, the available props are based on the div element.
*/
avatar: SlotProps<'div', CardHeaderAvatarSlotPropsOverrides, CardHeaderOwnerState>;
/**
* Props forwarded to the action slot.
* By default, the available props are based on the div element.
*/
action: SlotProps<'div', CardHeaderActionSlotPropsOverrides, CardHeaderOwnerState>;
/**
* Props forwarded to the content slot.
* By default, the available props are based on the div element.
*/
content: SlotProps<'div', CardHeaderContentSlotPropsOverrides, CardHeaderOwnerState>;
/**
* Props forwarded to the title slot (as long as disableTypography is not `true`).
* By default, the available props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component.
*/
title:
| TypographyProps<
TitleTypographyComponent,
{ component?: TitleTypographyComponent | undefined } & CardHeaderTitleSlotPropsOverrides
>
| ((
ownerState: CardHeaderOwnerState,
) => TypographyProps<
TitleTypographyComponent,
{ component?: TitleTypographyComponent | undefined } & CardHeaderTitleSlotPropsOverrides
>);
/**
* Props forwarded to the subheader slot (as long as disableTypography is not `true`).
* By default, the available props are based on the [Typography](https://mui.com/material-ui/api/typography/#props) component.
*/
subheader:
| TypographyProps<
SubheaderTypographyComponent,
{
component?: SubheaderTypographyComponent | undefined;
} & CardHeaderSubheaderSlotPropsOverrides
>
| ((ownerState: CardHeaderOwnerState) => TypographyProps<
SubheaderTypographyComponent,
{
component?: SubheaderTypographyComponent | undefined;
} & CardHeaderSubheaderSlotPropsOverrides
>);
}
>;
export interface CardHeaderOwnProps {
/**
* The action to display in the card header.
*/
action?: React.ReactNode;
/**
* The Avatar element to display.
*/
avatar?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<CardHeaderClasses> | undefined;
/**
* If `true`, `subheader` and `title` won't be wrapped by a Typography component.
* This can be useful to render an alternative Typography variant by wrapping
* the `title` text, and optional `subheader` text
* with the Typography component.
* @default false
*/
disableTypography?: boolean | undefined;
/**
* The content of the component.
*/
subheader?: React.ReactNode;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The content of the component.
*/
title?: React.ReactNode;
}
export interface CardHeaderOwnerState extends CardHeaderOwnProps {}
export interface CardHeaderTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'div',
TitleTypographyComponent extends React.ElementType = 'span',
SubheaderTypographyComponent extends React.ElementType = 'span',
> {
props: AdditionalProps &
CardHeaderOwnProps &
CardHeaderSlotsAndSlotProps<TitleTypographyComponent, SubheaderTypographyComponent>;
defaultComponent: RootComponent;
}
declare const CardHeader: OverridableCardHeader;
export interface OverridableCardHeader extends OverridableComponent<CardHeaderTypeMap> {
<
RootComponent extends React.ElementType = CardHeaderTypeMap['defaultComponent'],
AdditionalProps = {},
TitleTypographyComponent extends React.ElementType = 'span',
SubheaderTypographyComponent extends React.ElementType = 'span',
>(
props: CardHeaderPropsWithComponent<
RootComponent,
AdditionalProps,
TitleTypographyComponent,
SubheaderTypographyComponent
>,
): React.JSX.Element;
}
export type CardHeaderProps<
RootComponent extends React.ElementType = CardHeaderTypeMap['defaultComponent'],
AdditionalProps = {},
TitleTypographyComponent extends React.ElementType = 'span',
SubheaderTypographyComponent extends React.ElementType = 'span',
> = OverrideProps<
CardHeaderTypeMap<
AdditionalProps,
RootComponent,
TitleTypographyComponent,
SubheaderTypographyComponent
>,
RootComponent
>;
export type CardHeaderPropsWithComponent<
RootComponent extends React.ElementType = CardHeaderTypeMap['defaultComponent'],
AdditionalProps = {},
TitleTypographyComponent extends React.ElementType = 'span',
SubheaderTypographyComponent extends React.ElementType = 'span',
> = {
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component?: RootComponent | undefined;
} & CardHeaderProps<
RootComponent,
AdditionalProps,
TitleTypographyComponent,
SubheaderTypographyComponent
>;
vendor/src/CardMedia/CardMedia.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { CardMediaClasses } from './cardMediaClasses';
export interface CardMediaOwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<CardMediaClasses> | undefined;
/**
* Image to be displayed as a background image.
* Either `image` or `src` prop must be specified.
* Note that caller must specify height otherwise the image will not be visible.
*/
image?: string | undefined;
/**
* An alias for `image` property.
* Available only with media components.
* Media components: `video`, `audio`, `picture`, `iframe`, `img`.
*/
src?: string | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface CardMediaTypeMap<AdditionalProps, RootComponent extends React.ElementType> {
props: AdditionalProps & CardMediaOwnProps;
defaultComponent: RootComponent;
}
declare const CardMedia: OverridableComponent<CardMediaTypeMap<{}, 'div'>>;
export type CardMediaProps<
RootComponent extends React.ElementType = 'div',
AdditionalProps = {},
> = OverrideProps<CardMediaTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
vendor/src/Collapse/Collapse.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { InternalStandardProps as StandardProps } from '../internal';
import { TransitionProps, TransitionStatus } from '../transitions/types';
import { CollapseClasses } from './collapseClasses';
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
export interface CollapseSlots {
/**
* The component that renders the root.
* @default 'div'
*/
root?: React.ElementType | undefined;
/**
* The component that renders the wrapper.
* @default 'div'
*/
wrapper?: React.ElementType | undefined;
/**
* The component that renders the inner wrapper.
* @default 'div'
*/
wrapperInner?: React.ElementType | undefined;
}
export interface CollapseRootSlotPropsOverrides {}
export interface CollapseWrapperSlotPropsOverrides {}
export interface CollapseWrapperInnerSlotPropsOverrides {}
export type CollapseSlotsAndSlotProps = CreateSlotsAndSlotProps<
CollapseSlots,
{
root: SlotProps<'div', CollapseRootSlotPropsOverrides, CollapseOwnerState>;
wrapper: SlotProps<'div', CollapseWrapperSlotPropsOverrides, CollapseOwnerState>;
wrapperInner: SlotProps<'div', CollapseWrapperInnerSlotPropsOverrides, CollapseOwnerState>;
}
>;
export interface CollapseProps
extends StandardProps<TransitionProps, 'timeout'>, CollapseSlotsAndSlotProps {
/**
* Add a custom transition end trigger.
* Use it when you need custom logic to decide when the transition has ended.
* Note: Timeouts are still used as a fallback if provided.
*
* @param {HTMLElement} node The transitioning DOM node.
* @param {Function} done Call this when the transition has finished.
*/
addEndListener?: TransitionProps['addEndListener'] | undefined;
/**
* The content node to be collapsed.
*/
children?: React.ReactNode;
className?: string | undefined;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<CollapseClasses> | undefined;
/**
* The width (horizontal) or height (vertical) of the container when collapsed.
* @default '0px'
*/
collapsedSize?: string | number | undefined;
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component?: React.ElementType<TransitionProps> | undefined;
/**
* If `true`, the transition ignores `theme.motion.reducedMotion` and keeps its normal timing.
* @default false
*/
disablePrefersReducedMotion?: boolean | undefined;
/**
* The transition timing function.
* You may specify a single easing or a object containing enter and exit values.
*/
easing?: TransitionProps['easing'] | undefined;
/**
* If `true`, the component will transition in.
*/
in?: boolean | undefined;
/**
* The transition orientation.
* @default 'vertical'
*/
orientation?: 'horizontal' | 'vertical' | undefined;
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*
* Set to 'auto' to automatically calculate transition time based on height.
* @default duration.standard
*/
timeout?: TransitionProps['timeout'] | 'auto' | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface CollapseOwnerState extends CollapseProps {
state: TransitionStatus;
}
export default function Collapse(props: CollapseProps): React.JSX.Element;
vendor/src/Paper/Paper.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { OverridableStringUnion } from '@mui/types';
import { Theme } from '../styles';
import { OverrideProps, OverridableComponent, OverridableTypeMap } from '../OverridableComponent';
import { PaperClasses } from './paperClasses';
export interface PaperPropsVariantOverrides {}
export interface PaperOwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<PaperClasses> | undefined;
/**
* Shadow depth, corresponds to `dp` in the spec.
* It accepts values between 0 and 24 inclusive.
* @default 1
*/
elevation?: number | undefined;
/**
* If `true`, rounded corners are disabled.
* @default false
*/
square?: boolean | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The variant to use.
* @default 'elevation'
*/
variant?:
OverridableStringUnion<'elevation' | 'outlined', PaperPropsVariantOverrides> | undefined;
}
export interface PaperTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'div',
> {
props: AdditionalProps & PaperOwnProps;
defaultComponent: RootComponent;
}
declare const Paper: OverridableComponent<PaperTypeMap>;
export interface ExtendPaperTypeMap<TypeMap extends OverridableTypeMap, Keys extends string = ''> {
props: TypeMap['props'] & Omit<PaperTypeMap['props'], Keys>;
defaultComponent: TypeMap['defaultComponent'];
}
export type PaperProps<
RootComponent extends React.ElementType = PaperTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<PaperTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
安装后验收
执行严格类型检查、生产构建和实际交互。检查键盘标签/焦点、原生支持的禁用/错误/只读语义、深浅色、窄屏和减少动画。按真实宿主数据检查回调,不把复制提示词当作安装完成。初始化工具还需检查服务端 HTML 与无告警水合。
来源与许可
https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e
MIT · @mui/material@9.4.0. 保留上游原始内容与许可证。上游完整原文保留于 vendor/docs,不标为全文中文化。