JGuang

进度指示

Progress · Material UI

交互预览
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1

进度指示

表达待处理活动,或展示给定的数值进度。

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

使用场景与业务边界

确定进度需要真实业务数值;动画不证明请求正在运行或已经完成。

原生组成与范围

CircularProgress, LinearProgress

保持 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 结构、可空值与泛型仍按固定源码保留。

所属组件.属性用途说明声明来源
CircularProgress.variant所属组件的原生视觉枚举,不可替换为通用 variant 属性。CircularProgress
CircularProgress.value受控原生值,其单值/数组/可空类型取决于所属组件。CircularProgress
LinearProgress.variant所属组件的原生视觉枚举,不可替换为通用 variant 属性。LinearProgress
LinearProgress.value受控原生值,其单值/数组/可空类型取决于所属组件。LinearProgress
LinearProgress.valueBuffer宿主提供的缓冲进度,与已完成进度不同。LinearProgress

可运行原生示例

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

  • 不确定值环形进度 · CircularIndeterminate · 上游原生示例
  • 环形进度颜色 · CircularColor · 上游原生示例
  • 环形进度尺寸 · CircularSize · 上游原生示例
  • 确定值环形进度 · CircularDeterminate · 上游原生示例
  • 环形进度自定义缩放 · CircularCustomScale · 上游原生示例
  • 环形进度轨道 · CircularEnableTrack · 上游原生示例
  • 交互集成 · CircularIntegration · 上游原生示例
  • 带标签的环形进度 · CircularWithValueLabel · 上游原生示例
  • 不确定值线性进度 · LinearIndeterminate · 上游原生示例
  • 查询线性进度 · LinearQuery · 上游原生示例
  • 线性进度颜色 · LinearColor · 上游原生示例
  • 确定值线性进度 · LinearDeterminate · 上游原生示例
  • 缓冲线性进度 · LinearBuffer · 上游原生示例
  • 带标签的线性进度 · LinearWithValueLabel · 上游原生示例
  • 自定义数值文本的线性进度 · LinearWithAriaValueText · 上游原生示例
  • 定制样式 · CustomizedProgressBars · 上游原生示例
  • 延迟显示 · DelayingAppearance · 上游原生示例
  • 高负载下的进度展示 · CircularUnderLoad · 上游原生示例

真实使用示例

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

import CircularProgress from '@mui/material/CircularProgress';
import Box from '@mui/material/Box';

export default function CircularIndeterminate() {
  return (
    <Box sx={{ display: 'flex' }}>
      <CircularProgress aria-label="Loading…" />
    </Box>
  );
}

示例依赖边界

@mui/material/CircularProgress, @mui/material/Box, @mui/material/Stack, react, @mui/material/colors, @mui/material/Button, @mui/material/Fab, @mui/icons-material/Check, @mui/icons-material/Save, @mui/material/Typography, @mui/material/LinearProgress, @mui/material/styles, @mui/material/Fade

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

固定上游 API 元数据参考

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

CircularProgress

import CircularProgress from '@mui/material/CircularProgress';
import { CircularProgress } from '@mui/material';
属性必需上游元数据类型/约束元数据默认值
classes否object—
color否'inherit' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | string'primary'
disableShrink否boolfalse
enableTrackSlot否boolfalse
max否number100
min否number0
size否number | string40
sx否Array<func | object | bool> | func | object—
thickness否number3.6
value否numberprops.min ?? 0
variant否'determinate' | 'indeterminate''indeterminate'

LinearProgress

import LinearProgress from '@mui/material/LinearProgress';
import { LinearProgress } from '@mui/material';
属性必需上游元数据类型/约束元数据默认值
classes否object—
color否'inherit' | 'primary' | 'secondary' | string'primary'
max否number100
min否number0
sx否Array<func | object | bool> | func | object—
value否number—
valueBuffer否number—
variant否'buffer' | 'determinate' | 'indeterminate' | 'query''indeterminate'

原生源码声明

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

vendor/src/CircularProgress/CircularProgress.d.ts

import * as React from 'react';

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

import { OverridableStringUnion } from '@mui/types';

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

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

import { CircularProgressClasses } from './circularProgressClasses';

export interface CircularProgressPropsColorOverrides {}

export interface CircularProgressPropsVariantOverrides {}

export interface CircularProgressProps extends StandardProps<
  React.HTMLAttributes<HTMLSpanElement>,
  'children'
> {
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<CircularProgressClasses> | undefined;
  /**
   * The color of the component.
   * It supports both default and custom theme colors, which can be added as shown in the
   * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
   * @default 'primary'
   */
  color?:
    | OverridableStringUnion<
        'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'inherit',
        CircularProgressPropsColorOverrides
      >
    | undefined;
  /**
   * If `true`, the shrink animation is disabled.
   * This only works if variant is `indeterminate`.
   * @default false
   */
  disableShrink?: boolean | undefined;
  /**
   * If `true`, a track circle slot is mounted to show a subtle background for the progress.
   * The `size` and `thickness` apply to the track slot to be consistent with the progress circle.
   * @default false
   */
  enableTrackSlot?: boolean | undefined;
  /**
   * The maximum value for the progress indicator for the determinate variant.
   * @default 100
   */
  max?: number | undefined;
  /**
   * The minimum value for the progress indicator for the determinate variant.
   * @default 0
   */
  min?: number | undefined;
  /**
   * The size of the component.
   * If using a number, the pixel unit is assumed.
   * If using a string, you need to provide the CSS unit, for example '3rem'.
   * @default 40
   */
  size?: number | string | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
  /**
   * The thickness of the circle.
   * @default 3.6
   */
  thickness?: number | undefined;
  /**
   * The value of the progress indicator for the determinate variant.
   * Value between `min` and `max`.
   * @default props.min ?? 0
   */
  value?: number | undefined;
  /**
   * The variant to use.
   * Use indeterminate when there is no progress value.
   * @default 'indeterminate'
   */
  variant?:
    | OverridableStringUnion<'determinate' | 'indeterminate', CircularProgressPropsVariantOverrides>
    | undefined;
}

export default function CircularProgress(props: CircularProgressProps): React.JSX.Element;

vendor/src/LinearProgress/LinearProgress.d.ts

import * as React from 'react';

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

import { OverridableStringUnion } from '@mui/types';

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

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

import { LinearProgressClasses } from './linearProgressClasses';

export interface LinearProgressPropsColorOverrides {}

export interface LinearProgressPropsVariantOverrides {}

export interface LinearProgressProps extends StandardProps<
  React.HTMLAttributes<HTMLSpanElement>,
  'children'
> {
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<LinearProgressClasses> | undefined;
  /**
   * The color of the component.
   * It supports both default and custom theme colors, which can be added as shown in the
   * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
   * @default 'primary'
   */
  color?:
    | OverridableStringUnion<
        'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'inherit',
        LinearProgressPropsColorOverrides
      >
    | undefined;
  /**
   * The maximum value for the progress indicator for the determinate and buffer variants.
   * @default 100
   */
  max?: number | undefined;
  /**
   * The minimum value for the progress indicator for the determinate and buffer variants.
   * @default 0
   */
  min?: number | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
  /**
   * The value of the progress indicator for the determinate and buffer variants.
   * Value between `min` and `max`.
   */
  value?: number | undefined;
  /**
   * The value for the buffer variant.
   * Value between `min` and `max`.
   */
  valueBuffer?: number | undefined;
  /**
   * The variant to use.
   * Use indeterminate or query when there is no progress value.
   * @default 'indeterminate'
   */
  variant?:
    | OverridableStringUnion<
        'determinate' | 'indeterminate' | 'buffer' | 'query',
        LinearProgressPropsVariantOverrides
      >
    | undefined;
}

export default function LinearProgress(props: LinearProgressProps): React.JSX.Element;

安装后验收

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

来源与许可

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

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