跳转到内容

LoadingButton API

想要学习更多组件属性和 CSS API,可以查阅 React LoadingButton 组件的 API 文档。

导入

import LoadingButton from '@mui/lab/LoadingButton';
// 或
import { LoadingButton } from '@mui/lab';
你可以阅读这个关于最小化捆绑包的指南以了解以上二者的差异。

组件名称

在主题中,名称“MuiLoadingButton”可用于提供默认属性(props),或者样式覆盖

属性

Button 组件的属性也是可用的。

名称类型默认值描述
childrennode
The content of the component.
classesobject
Override or extend the styles applied to the component. See CSS API below for more details.
disabledboolfalse
如果被设置为 true,那么该组件将会被禁用。
loadingboolfalse
If true, the loading indicator is shown.
loadingIndicatornode<CircularProgress color="inherit" size={16} />
Element placed before the children if the button is in loading state. The node should contain an element with role="progressbar" with an accessible name. By default we render a CircularProgress that is labelled by the button itself.
loadingPosition'start'
| 'end'
| 'center'
'center'
The loading indicator can be positioned on the start, end, or the center of the button.
sxArray<func
| object
| bool>
| func
| object
The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details.
variant'contained'
| 'outlined'
| 'text'
| string
'text'
The variant to use.

ref 则会被传递到根元素中。

继承

尽管上文没有明文记录, Button 组件 的属性(props) 在组件LoadingButton上同样是可用的。 你可以利用这一点来 指向嵌套组件

CSS

规则名称全局类名描述
root.MuiLoadingButton-rootStyles applied to the root element.
text.MuiLoadingButton-textStyles applied to the root element if variant="text".
textInherit.MuiLoadingButton-textInheritStyles applied to the root element if variant="text" and color="inherit".
textPrimary.MuiLoadingButton-textPrimaryStyles applied to the root element if variant="text" and color="primary".
textSecondary.MuiLoadingButton-textSecondaryStyles applied to the root element if variant="text" and color="secondary".
textSuccess.MuiLoadingButton-textSuccessStyles applied to the root element if variant="text" and color="success".
textError.MuiLoadingButton-textErrorStyles applied to the root element if variant="text" and color="error".
textInfo.MuiLoadingButton-textInfoStyles applied to the root element if variant="text" and color="info".
textWarning.MuiLoadingButton-textWarningStyles applied to the root element if variant="text" and color="warning".
outlined.MuiLoadingButton-outlinedStyles applied to the root element if variant="outlined".
outlinedInherit.MuiLoadingButton-outlinedInheritStyles applied to the root element if variant="outlined" and color="inherit".
outlinedPrimary.MuiLoadingButton-outlinedPrimaryStyles applied to the root element if variant="outlined" and color="primary".
outlinedSecondary.MuiLoadingButton-outlinedSecondaryStyles applied to the root element if variant="outlined" and color="secondary".
outlinedSuccess.MuiLoadingButton-outlinedSuccessStyles applied to the root element if variant="outlined" and color="success".
outlinedError.MuiLoadingButton-outlinedErrorStyles applied to the root element if variant="outlined" and color="error".
outlinedInfo.MuiLoadingButton-outlinedInfoStyles applied to the root element if variant="outlined" and color="info".
outlinedWarning.MuiLoadingButton-outlinedWarningStyles applied to the root element if variant="outlined" and color="warning".
contained.MuiLoadingButton-containedStyles applied to the root element if variant="contained".
containedInherit.MuiLoadingButton-containedInheritStyles applied to the root element if variant="contained" and color="inherit".
containedPrimary.MuiLoadingButton-containedPrimaryStyles applied to the root element if variant="contained" and color="primary".
containedSecondary.MuiLoadingButton-containedSecondaryStyles applied to the root element if variant="contained" and color="secondary".
containedSuccess.MuiLoadingButton-containedSuccessStyles applied to the root element if variant="contained" and color="success".
containedInfo.MuiLoadingButton-containedInfoStyles applied to the root element if variant="contained" and color="info".
containedError.MuiLoadingButton-containedErrorStyles applied to the root element if variant="contained" and color="error".
containedWarning.MuiLoadingButton-containedWarningStyles applied to the root element if variant="contained" and color="warning".
disableElevation.MuiLoadingButton-disableElevationStyles applied to the root element if disableElevation={true}.
focusVisible.Mui-focusVisiblePseudo-class applied to the ButtonBase root element if the button is keyboard focused.
disabled.Mui-disabledPseudo-class applied to the root element if disabled={true}.
colorInherit.MuiLoadingButton-colorInheritStyles applied to the root element if color="inherit".
textSizeSmall.MuiLoadingButton-textSizeSmallStyles applied to the root element if size="small" and variant="text".
textSizeMedium.MuiLoadingButton-textSizeMediumStyles applied to the root element if size="medium" and variant="text".
textSizeLarge.MuiLoadingButton-textSizeLargeStyles applied to the root element if size="large" and variant="text".
outlinedSizeSmall.MuiLoadingButton-outlinedSizeSmallStyles applied to the root element if size="small" and variant="outlined".
outlinedSizeMedium.MuiLoadingButton-outlinedSizeMediumStyles applied to the root element if size="medium" and variant="outlined".
outlinedSizeLarge.MuiLoadingButton-outlinedSizeLargeStyles applied to the root element if size="large" and variant="outlined".
containedSizeSmall.MuiLoadingButton-containedSizeSmallStyles applied to the root element if size="small" and variant="contained".
containedSizeMedium.MuiLoadingButton-containedSizeMediumStyles applied to the root element if size="small" and variant="contained".
containedSizeLarge.MuiLoadingButton-containedSizeLargeStyles applied to the root element if size="large" and variant="contained".
sizeSmall.MuiLoadingButton-sizeSmallStyles applied to the root element if size="small".
sizeMedium.MuiLoadingButton-sizeMediumStyles applied to the root element if size="medium".
sizeLarge.MuiLoadingButton-sizeLargeStyles applied to the root element if size="large".
fullWidth.MuiLoadingButton-fullWidthStyles applied to the root element if fullWidth={true}.
startIcon.MuiLoadingButton-startIconStyles applied to the startIcon element if supplied.
endIcon.MuiLoadingButton-endIconStyles applied to the endIcon element if supplied.
iconSizeSmall.MuiLoadingButton-iconSizeSmallStyles applied to the icon element if supplied and size="small".
iconSizeMedium.MuiLoadingButton-iconSizeMediumStyles applied to the icon element if supplied and size="medium".
iconSizeLarge.MuiLoadingButton-iconSizeLargeStyles applied to the icon element if supplied and size="large".
loading.MuiLoadingButton-loadingStyles applied to the root element if loading={true}.
loadingIndicator.MuiLoadingButton-loadingIndicatorStyles applied to the loadingIndicator element.
loadingIndicatorCenter.MuiLoadingButton-loadingIndicatorCenterStyles applied to the loadingIndicator element if loadingPosition="center".
loadingIndicatorStart.MuiLoadingButton-loadingIndicatorStartStyles applied to the loadingIndicator element if loadingPosition="start".
loadingIndicatorEnd.MuiLoadingButton-loadingIndicatorEndStyles applied to the loadingIndicator element if loadingPosition="end".
endIconLoadingEnd.MuiLoadingButton-endIconLoadingEndStyles applied to the endIcon element if loading={true} and loadingPosition="end".
startIconLoadingStart.MuiLoadingButton-startIconLoadingStartStyles applied to the startIcon element if loading={true} and loadingPosition="start".

您可以使用组件自定义选项对组件进行个性化:

演示项目