MobileStepperAPI
React MobileStepper 组件的 API 参考文档。了解此导出模块的 props、CSS 和其他 API。
演示
导入
import MobileStepper from '@mui/material/MobileStepper';
// or
import { MobileStepper } from '@mui/material';
了解更多关于差异的信息,请阅读关于最小化 bundle size 的指南。
Paper 组件的 Props 也可用。
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
steps* | integer | - | 总步数。 |
activeStep | integer | 0 | 设置活动步骤(从零开始的索引)。定义当 variant 为 'dots' 时哪个点被高亮显示。 |
backButton | node | - | 后退按钮元素。例如,它可以是 |
classes | object | - | 覆盖或扩展应用于组件的样式。 有关更多详细信息,请参阅下面的 CSS 类 API。 |
LinearProgressProps | object | - | 应用于 |
nextButton | node | - | 前进按钮元素。例如,它可以是 |
position | 'bottom' | 'static' | 'top' | 'bottom' | 设置定位类型。 |
slotProps | { dot?: func | object, dots?: func | object, progress?: func | object, root?: func | object } | {} | 用于内部每个 slot 的 props。 |
slots | { dot?: elementType, dots?: elementType, progress?: elementType, root?: elementType } | {} | 用于内部每个 slot 的组件。 |
sx | Array<func | object | bool> | func | object | - | 允许定义系统覆盖以及其他 CSS 样式的系统 prop。 有关更多详细信息,请参阅 `sx` 页面。 |
variant | 'dots' | 'progress' | 'text' | 'dots' | 要使用的 variant。 |
该组件无法保存 ref。
继承
虽然上面没有明确文档说明,但 Paper 组件的 props 也可在 MobileStepper 中使用。您可以利用这一点来定位嵌套组件。
主题默认 props
您可以使用 MuiMobileStepper
通过主题更改此组件的默认 props。
Slot 名称 | 类名 | 默认组件 | 描述 |
---|---|---|---|
root | .MuiMobileStepper-root | Paper | 渲染 root slot 的组件。 |
progress | .MuiMobileStepper-progress | LinearProgress | 渲染 progress slot 的组件。 |
dots | .MuiMobileStepper-dots | 'div' | 渲染 dots slot 的组件。 |
dot | .MuiMobileStepper-dot | 'div' | 渲染 dot slot 的组件。 |
这些类名对于使用 CSS 进行样式设置很有用。当触发特定状态时,它们会应用于组件的 slots。
类名 | 规则名称 | 描述 |
---|---|---|
.MuiMobileStepper-dotActive | dotActive | 如果 variant="dots" 且这是活动步骤,则应用于点的样式。 |
.MuiMobileStepper-positionBottom | positionBottom | 如果 position="bottom" ,则应用于 root 元素的样式。 |
.MuiMobileStepper-positionStatic | positionStatic | 如果 position="static" ,则应用于 root 元素的样式。 |
.MuiMobileStepper-positionTop | positionTop | 如果 position="top" ,则应用于 root 元素的样式。 |
您可以使用以下自定义选项之一覆盖组件的样式
- 使用全局类名。
- 使用规则名称作为自定义主题中组件的
styleOverrides
属性的一部分。
源代码
如果您在此页面中没有找到所需的信息,请考虑查看组件的实现以获取更多详细信息。