Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stepper] Fix optional label is not centered when alternativeLabel is used #34335

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/mui-material/src/StepLabel/StepLabel.js
Expand Up @@ -36,7 +36,7 @@ const useUtilityClasses = (ownerState) => {
disabled && 'disabled',
alternativeLabel && 'alternativeLabel',
],
labelContainer: ['labelContainer'],
labelContainer: ['labelContainer', alternativeLabel && 'alternativeLabel'],
};

return composeClasses(slots, getStepLabelUtilityClass, classes);
Expand Down Expand Up @@ -84,7 +84,6 @@ const StepLabelLabel = styled('span', {
fontWeight: 500,
},
[`&.${stepLabelClasses.alternativeLabel}`]: {
textAlign: 'center',
marginTop: 16,
},
[`&.${stepLabelClasses.error}`]: {
Expand Down Expand Up @@ -112,6 +111,9 @@ const StepLabelLabelContainer = styled('span', {
})(({ theme }) => ({
width: '100%',
color: (theme.vars || theme).palette.text.secondary,
[`&.${stepLabelClasses.alternativeLabel}`]: {
ZeeshanTamboli marked this conversation as resolved.
Show resolved Hide resolved
textAlign: 'center',
},
}));

const StepLabel = React.forwardRef(function StepLabel(inProps, ref) {
Expand Down
@@ -0,0 +1,21 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
import StepLabel from '@mui/material/StepLabel';

const steps = ['Select master blaster campaign settings', 'Create an ad group', 'Create an ad'];

export default function AlternativeLabelOptionalText() {
return (
<Box sx={{ width: '100%' }}>
<Stepper activeStep={1} alternativeLabel>
{steps.map((label) => (
<Step key={label} expanded>
<StepLabel optional="optional">{label}</StepLabel>
</Step>
))}
</Stepper>
</Box>
);
}