Skip to content

Commit 0a161cc

Browse files
committed
Apply useSlot to LinearProgress
1 parent ef960bb commit 0a161cc

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

packages/mui-joy/src/LinearProgress/LinearProgress.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { unstable_composeClasses as composeClasses } from '@mui/base';
2-
import { useSlotProps } from '@mui/base/utils';
32
import { css, keyframes } from '@mui/system';
43
import { OverridableComponent } from '@mui/types';
54
import { unstable_capitalize as capitalize } from '@mui/utils';
@@ -8,6 +7,7 @@ import PropTypes from 'prop-types';
87
import * as React from 'react';
98
import styled from '../styles/styled';
109
import useThemeProps from '../styles/useThemeProps';
10+
import useSlot from '../utils/useSlot';
1111
import { getLinearProgressUtilityClass } from './linearProgressClasses';
1212
import {
1313
LinearProgressOwnerState,
@@ -145,7 +145,6 @@ const LinearProgress = React.forwardRef(function LinearProgress(inProps, ref) {
145145
});
146146

147147
const {
148-
component = 'div',
149148
children,
150149
className,
151150
color = 'primary',
@@ -170,30 +169,28 @@ const LinearProgress = React.forwardRef(function LinearProgress(inProps, ref) {
170169

171170
const classes = useUtilityClasses(ownerState);
172171

173-
const rootProps = useSlotProps({
172+
const [SlotRoot, rootProps] = useSlot('root', {
173+
ref,
174+
className: clsx(classes.root, className),
174175
elementType: LinearProgressRoot,
175-
externalSlotProps: {},
176176
externalForwardedProps: other,
177177
ownerState,
178178
additionalProps: {
179-
ref,
180-
as: component,
181179
role: 'progressbar',
182180
style: {
183181
// Setting this CSS varaible via inline-style
184182
// prevents the generation of new CSS every time
185183
// `value` prop updates
186184
'--LinearProgress-percent': value,
187185
},
186+
...(typeof value === 'number' &&
187+
determinate && {
188+
'aria-valuenow': Math.round(value),
189+
}),
188190
},
189-
className: clsx(classes.root, className),
190-
...(typeof value === 'number' &&
191-
determinate && {
192-
'aria-valuenow': Math.round(value),
193-
}),
194191
});
195192

196-
return <LinearProgressRoot {...rootProps}>{children}</LinearProgressRoot>;
193+
return <SlotRoot {...rootProps}>{children}</SlotRoot>;
197194
}) as OverridableComponent<LinearProgressTypeMap>;
198195

199196
LinearProgress.propTypes /* remove-proptypes */ = {

0 commit comments

Comments
 (0)