Skip to content

[stepper] Proper support for vertical alternativeLabel#48485

Merged
silviuaavram merged 4 commits into
mui:masterfrom
silviuaavram:feat/alternative-label-vertical-stepper
May 12, 2026
Merged

[stepper] Proper support for vertical alternativeLabel#48485
silviuaavram merged 4 commits into
mui:masterfrom
silviuaavram:feat/alternative-label-vertical-stepper

Conversation

@silviuaavram
Copy link
Copy Markdown
Member

@silviuaavram silviuaavram commented May 6, 2026

Properly support vertical orientation with alternativeLabel.

Move the steps and the content to the opposite side using variant overrides. Another option would have been to ignore the alternativeLabel prop when vertical orientation is used, and show a warning. But supporting it visually without showing a broken UI seems to be better.

Before After
Screenshot 2026-05-06 at 17 01 31 Screenshot 2026-05-06 at 16 57 04

@silviuaavram silviuaavram added scope: stepper Changes related to the stepper. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. labels May 6, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 6, 2026

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+1.12KB(+0.22%) 🔺+101B(+0.07%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Material UI Stepper styling so alternativeLabel works properly when the Stepper is in vertical orientation, primarily by mirroring/alignment adjustments across Step, StepLabel, StepConnector, and StepContent.

Changes:

  • Add vertical + alternativeLabel styling variants to align the stepper/labels/connectors for the mirrored vertical layout.
  • Update StepContent to consume alternativeLabel from StepperContext and apply right-aligned spacing/border styles when enabled.
  • Refine Step variants to differentiate horizontal vs vertical alternativeLabel layout behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/mui-material/src/Stepper/Stepper.js Adds a vertical+alternativeLabel variant to adjust cross-axis alignment.
packages/mui-material/src/StepLabel/StepLabel.js Adds vertical+alternativeLabel variants to flip label layout and adjust spacing/alignment.
packages/mui-material/src/StepContent/StepContent.js Adds alternativeLabel styling for mirrored vertical content and threads alternativeLabel into ownerState.
packages/mui-material/src/StepConnector/StepConnector.js Splits alternativeLabel handling by orientation and adds vertical+alternativeLabel margins.
packages/mui-material/src/Step/Step.js Adds new variants for horizontal (non-alt) and vertical (alt) layouts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/mui-material/src/Step/Step.js
Comment thread packages/mui-material/src/StepContent/StepContent.js
Comment thread packages/mui-material/src/StepContent/StepContent.js
Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be either in the docs demo or regression to appear in Argos.

Comment thread packages/mui-material/src/StepLabel/StepLabel.js Outdated
Comment thread packages/mui-material/src/StepLabel/StepLabel.js Outdated
@siriwatknp
Copy link
Copy Markdown
Member

The alternativeLabel JSDoc on Stepper.d.ts:18 still says "If set to true and orientation is horizontal, then the step label will be positioned under the icon." Since this PR generalizes the prop to vertical, please update the JSDoc and re-run pnpm proptypes so the docs reflect the new behavior.

@silviuaavram silviuaavram force-pushed the feat/alternative-label-vertical-stepper branch from 50ecfb0 to b9542d9 Compare May 7, 2026 14:40
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label May 7, 2026
@silviuaavram silviuaavram changed the title [Stepper] Proper support for vertical alternativeLabel [stepper] Proper support for vertical alternativeLabel May 8, 2026
@silviuaavram silviuaavram force-pushed the feat/alternative-label-vertical-stepper branch from b9542d9 to 431dd68 Compare May 8, 2026 07:09
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label May 8, 2026
Comment on lines +76 to +78
[`&.${stepLabelClasses.alternativeLabel}`]: {
flexDirection: 'row-reverse',
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is strange. it's either variant or classname, not both.

{
      props: { orientation: 'vertical', alternativeLabel: true },
      style: { flexDirection: 'row-reverse' }
}

or

 …base styles
  [`&.${stepLabelClasses.alternativeLabel}`]: {
    flexDirection: 'row-reverse',
  }

Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment on the variants vs class selector. Also, the structure of the StepConnector is different (it's within li which is correct markup), do you plan to update other demo in a separate PR?

no objection, but the support of alternativeLabel like this I could not have think of a use case:

Image

Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

and

Image

Comment thread packages/mui-material/src/Stepper/Stepper.d.ts
Comment thread docs/data/material/components/steppers/steppers.md Outdated
Copy link
Copy Markdown
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps not related to this PR, but it seems wrong that the Transition section is under the Vertical Stepper section in the docs.

@silviuaavram silviuaavram force-pushed the feat/alternative-label-vertical-stepper branch 2 times, most recently from 6e0bf80 to 27ed6fd Compare May 11, 2026 08:37
@silviuaavram silviuaavram force-pushed the feat/alternative-label-vertical-stepper branch from 27ed6fd to b017616 Compare May 11, 2026 08:39
@silviuaavram
Copy link
Copy Markdown
Member Author

Image and Image

Related to this, it's the text-align property. Not sure what to add instead, maybe leave it to the user? My main objective with this PR is to make the vertical+alernativeLabel example not look like we haven't even considered it. As mentioned above, the alternative would have been to thrown an error and not change anything. @siriwatknp

@mj12albert
Copy link
Copy Markdown
Member

Related to this, it's the text-align property.

Codex also flagged this:

StepContent sets textAlign: 'right' on the content root when alternativeLabel is true. That affects all nested content, including paragraphs, forms, and buttons, not just the stepper placement.

Maybe we could set text-align in the demo instead of the component? It would a bit better for users to set their own text-align as needed, rather than fight text align right if they didn't want it

Comment on lines 57 to 60
props: { orientation: 'vertical' },
style: {
flexDirection: 'column',
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex finding:

packages/mui-material/src/Stepper/Stepper.js makes vertical steppers a column, but packages/mui-material/src/Step/Step.js#L68 applies flex: 1 to every alternativeLabel step regardless of orientation. In a height-constrained vertical stepper – e.g. fixed height, a flex/grid parent, a drawer/sidebar layout – this makes steps grow and distribute vertically, unlike regular vertical steppers. Scope that rule to { orientation: 'horizontal', alternativeLabel: true }.

Copy link
Copy Markdown
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good ~

@silviuaavram silviuaavram merged commit 07dd8e7 into mui:master May 12, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: stepper Changes related to the stepper. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants