Skip to content

Refine Stepper component#42165

Merged
mdo merged 12 commits into
twbs:v6-devfrom
pricop:patch-9
Mar 18, 2026
Merged

Refine Stepper component#42165
mdo merged 12 commits into
twbs:v6-devfrom
pricop:patch-9

Conversation

@pricop

@pricop pricop commented Mar 13, 2026

Copy link
Copy Markdown

This PR changes the following on the BS6 stepper component:

  • Adds support for custom font-sizes (now defaults to sm variant)
  • Improves text alignment for horizontal steppers
  • Improved the stepper line weight by making it slightly thinner
  • Fixes gap between count bubble and text containers on horizontal steppers
  • Fixes height for text containers overflowing in unwanted places on horizontal steppers
  • Fixed RTL direction not displaying correctly
  • Opens the possibility for some very eye candy steppers 😍

I've created a comment for each change, so please bear with me until the end 😅.

New font-size variable and new font-size default


Since the counter bubble is customizable via --stepper-size CSS var, it makes sense for the for a --stepper-font-size to be present as well.

This also changes the default font-size to -sm size for the counter inside the bubble.

This is the perfect example where we should use the -sm variant, because the progress bar & the bubble are visually supportive elements. It also makes the bubble feel slightly more relaxed.

Before
v6-dev--twbs-bootstrap netlify app_docs_6 0_components_stepper_

After
localhost_9001_docs_6 0_components_stepper (2)

While subtle, when inspected on the screen, it makes a world of a difference.

@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

Smaller track-size

Changing the --stepper-track-size to .125rem further relaxes the component by taking away the attention from the track itself, allowing bubbles and text to be more easily readable at a glance without feeling overcrowded.

The industry standard is 1px or 2px at max for regular font-size. For much larger font-sizes, one can increase it to 4px or whatever, but the default should be smaller.

As a result, the stepper tracker has been reduced from 4px down to 2px.

Before
v6-dev--twbs-bootstrap netlify app_docs_6 0_components_stepper_ (1)

After
localhost_9001_docs_6 0_components_stepper (3)

For reference:

@pricop pricop changed the title Stepper font-size variable New fs variable, improved UI, several fixes. Mar 13, 2026
@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

Fixed text row for horizontal steppers

Because .stepper-item had grid-template-rows property set to repeat(2, var(--stepper-size));, it would force the 2nd row (the text row) to be as big in height as the counter bubble, and since the text was horizontally centered, it would make the spacing not be consistent with that of a vertical stepper.

Before
spacing1

After
spacing2

Furthermore, this also fixes something extremely important. Horizontal steppers will always be fighting for space on more condensed UIs (e.g: half screen container), and if the text is too long, with the old code having a forced height that was matching the bubble's height, the text would not fit, so it would start overflowing outside the container.

Before
v6-dev--twbs-bootstrap netlify app_docs_6 0_components_stepper_ (3)

After
localhost_9001_docs_6 0_components_stepper (4)

@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

Text alignment on horizontal steppers

Adding align-items property set to start for horizontal steppers, makes the text always start at the top, regardless of whether other columns overflow to multiple lines or not, therefore the spacing will always be equal between the count bubble and the text.

Before
localhost_9001_docs_6 0_components_stepper (4)

After
localhost_9001_docs_6 0_components_stepper (5)

@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

The best part

I saved the best part for the end 😅.

Since these changes don't limit us anymore to the height of the count bubble for the text container, we can now add help text, badge or any other type of decorations for the steps text, which imo is insanely helpful, as one could add a bit more information, without cluttering the UI.

Stepper with help text example:

localhost_9001_docs_6 0_components_stepper (10)

Mark-up:

<ol class="stepper stepper-horizontal w-100">
  <li class="stepper-item active"><div><div class="fw-semibold">Create</div><div class="small fg-secondary">Create an account.</div></div></li>
  <li class="stepper-item active"><div><div class="fw-semibold">Confirm</div><div class="small fg-secondary">Confirm your email.</div></div></li>
  <li class="stepper-item"><div><div class="fw-semibold">Set-up</div><div class="small fg-secondary">Configure your profile.</div></div></li>
  <li class="stepper-item"><div><div class="fw-semibold">Complete</div><div class="small fg-secondary">Welcome aboard!</div></div></li>
</ol>

Stepper with badge and theme variant example

localhost_9001_docs_6 0_components_stepper (13)

Mark-up:

<ol class="stepper stepper-horizontal w-100">
  <li class="stepper-item theme-success active"><div><div>Create account</div><div class="badge badge-subtle theme-success">Complete</div></div></li>
  <li class="stepper-item active"><div><div>Confirm email</div><div class="badge badge-subtle theme-primary">In-progress</div></div></li>
  <li class="stepper-item"><div><div>Update profile</div><div class="badge badge-subtle theme-secondary">Pending</div></div></li>
  <li class="stepper-item"><div><div>Finish</div><div class="badge badge-subtle theme-secondary">Pending</div></div></li>
</ol>

These could potentially even be included in the Documentation as an example on the variation section.

So for those more creative, this will also be an option, without having to change core Boostrap code to be able to achieve such results. 🙃

I did not made examples for vertical steppers, because for those there's always going to be decent space available to get creative.

@pricop pricop marked this pull request as ready for review March 13, 2026 03:08
@pricop pricop requested a review from a team as a code owner March 13, 2026 03:08
@pricop pricop changed the title New fs variable, improved UI, several fixes. New fs variable, improved UI, several fixes for Stepper component Mar 13, 2026
@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

Further improvement ideas

One last thing that perhaps you could change, since I'm not sure how or even if last active element should be targeted for this suggestion, but I strongly believe that the theme-color should change the color of the stepper line on the right side of the count bubble, not on the left side, except for the last active element, which should be gray on the right side.

Current

image

Even though the first step was "complete" by being marked with the success theme, the stepper line that goes towards the second step shows the primary color, which I feel it's off.

Improvement suggestion (I've photoshopped an example for you to have a look at).

image (2)

And a few reference images:
https://dribbble.com/shots/14012793-Stepper-Components
https://dribbble.com/shots/26376029-Stepper-Component-Visual-Progress-Tracker
https://dribbble.com/shots/24355595-Popup-Vertical-Stepper

I'm yet to find one that colors the line on the left side.

Let me know what do you think.

@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

RTL fix

Because of the usage of physical properties such as left, right, padding-left, the UI breaks when viewed in RTL.

I've added logical properties instead, and the stepper now displays correctly on both directions.

Before
v6-dev--twbs-bootstrap netlify app_docs_6 0_components_stepper_

After
localhost_9001_docs_6 0_components_stepper (3)

Hopefully this was it. Waiting for feedback on everything 😁.

@mdo

mdo commented Mar 13, 2026

Copy link
Copy Markdown
Member

Looking great! I'd love to see the examples you have at #42165 (comment) in a new section called Complex Steppers or something like that. Feel free to to do in this PR or a follow-up, dealer's choice.

Sidebar: we have the /examples page and I want to rethink that for v6. Probably make it more akin to our regular docs pages or something, unsure what we'll have time for in 6.0 vs 6.x.

@mdo mdo added this to v6.0.0 Mar 13, 2026
@github-project-automation github-project-automation Bot moved this to Inbox in v6.0.0 Mar 13, 2026
pricop added a commit to pricop/bootstrap that referenced this pull request Mar 13, 2026
I've added a new section called **Complex** to the **Stepper** component to demonstrate how this component can be used in different scenarios.

This is possible as part of: twbs#42165
@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

I've made a separate PR (#42174) for the Docs.

#42165 (comment) - what's your take on this? Do you think it should be changed so that the theme customizes the right side instead of the left side?

@pricop

pricop commented Mar 13, 2026

Copy link
Copy Markdown
Author

I've done it, this is the way it should work in my opinion.

If I reached "Step 3", then the lines leading to "Step 3" should be green, because the process leading to that step was complete.

Screenshot 2026-03-13 235551 Screenshot 2026-03-13 235601

Tested in all possible scenarios, including those where there could be gaps between "active" elements, when only first step is active, only the last step is active, RTL direction, etc.

Should be ready for merging 💪.

@mdo

mdo commented Mar 14, 2026

Copy link
Copy Markdown
Member

If I reached "Step 3", then the lines leading to "Step 3" should be green, because the process leading to that step was complete.

We could always look into gradients for stuff like this too :)

@pricop

pricop commented Mar 14, 2026

Copy link
Copy Markdown
Author

--stepper-gap set to high values such as 8rem breaks the horizontal lines, looking into it.

@pricop

pricop commented Mar 14, 2026

Copy link
Copy Markdown
Author

Yup, forgot to account for gap size when calcualting the width.

Fixed 🙃.

@pricop

pricop commented Mar 14, 2026

Copy link
Copy Markdown
Author

True, something like stepper-gradient class would be neat, however it would be rather complex to implement:

  • Start and ending bubbles would need to right, and to left gradients for Horizontal Stepper, and to top and to bottom for Vertical Stepper.
  • Middle lines would need radial gradients.
  • Middle lines would need to be twice as long, so colors blend in properly.
  • When there's a gap between active elements, would also require some dark magic to target those CSS selectors and apply the gradient in the proper direction(s).

Perhaps as a future update?

@pricop

pricop commented Mar 17, 2026

Copy link
Copy Markdown
Author

Went the extra mile and polished this up, so that both vertical and horizontal steppers now have the same capabilities.

  • Added the ability to create "complex" vertical steppers (with assistive text or whatever decorators one wants)
  • Added a new --stepper-text-gap var to control the space between text & bubble.
  • Improved positioning by switching to logical attributes
  • Fixed text becoming centered on both x and y axis when overflowing (prone on small screen displays)
  • Fixed the track lines becoming disjointed when the text of a bubble was overflowing (prone on small screen displays)

Issues fixed

Before (notice the track lines disjointed as well as the text becoming centered when it overflows)
v6-dev--twbs-bootstrap netlify app_docs_6 0_components_stepper_(iPhone SE) (1)

After (track lines now properly span across bubbles, and the text is always at the start when it overflows)
localhost_9001_docs_6 0_components_stepper(iPhone SE) (4)


New feature (complex vertical stepper) 🔥

localhost_9001_docs_6 0_components_stepper(iPhone SE) (3)

I'll also update the PR for Docs and switch one of the "Complex" examples to vertical mode, so that we display both variants in a complex state.

pricop added 6 commits March 17, 2026 18:47
Since the `--stepper-size` container is customizable, it makes sense for the `font-size` to be as well, when using larger sizes, larger font size may also be required.

This also changes the default `font-size` to `-sm` size for the counter inside the bubble.

This is the perfect example where if we use the `-sm` variant, it makes the text feel more relaxed inside the bubble.
This further relaxes the component by taking away the attention from the track itself, allowing bubbles and text to be more easily readable at a glance without feeling overcrowded.

 The industry standard is 1px or 2px at max.

As a result, the stepper tracker has been reduced to down to `2px`  from `4px`

For reference:
- Tailwind UI practices `2px` width: https://tailwindcss.com/plus/ui-blocks/application-ui/navigation/progress-bars#component-4b1efed043d1ab5688c705f2e27524f3
- Material UI practices `1px` width: https://material.angular.dev/components/stepper/overview
- Preline UI practices `1px` width: https://preline.co/docs/stepper.html
- Flowbite UI practices `1px` width: https://flowbite.com/docs/components/stepper/
- ReUI practices `1px` width: https://reui.io/patterns/stepper
This will make the text to always start at the top, regardless of whether other bubbles have a multi-line text or not.
Fixes the horizontal bottom row being fixed in height, causing the spacing between the count bubble and the text not be the same as intended (as the gap dictates), nor as its vertical stepper counterpart.

This also fixes the text overflowing outside fixed boundaries, causing it to move in places it shouldn't be.
Fixed RTL mode by making use of logical properties instead of physical ones.
Colored the right side stepper line instead of the left side for active elements.

This is the natural way, if I reached the next step, then the edge leading to it should be colored in the color of the completed step.
pricop and others added 6 commits March 17, 2026 18:47
Fixed stepper width not account for stepper's gap
- Added complex stepper support for vertical steppers.
- Added --stepper-text-gap CSS var (customizable spacing between text & bubble)
- Fixed text overflow for vertical steppers when the text is too long
Restored 1fr for the rows template. While I believed it looked better before, I'd rather keep the row size across all steps.
@mdo

mdo commented Mar 18, 2026

Copy link
Copy Markdown
Member

Rebased and made edits—once tests pass will merge. I've made steppers container-responsive instead of viewport-responsive. Also edited some docs and fixed the linter errors. @pricop You should double check you have the suggested extensions added for linting locally so your CI jobs don't fail for you :).

@mdo mdo changed the title New fs variable, improved UI, several fixes for Stepper component Refine Stepper component Mar 18, 2026
@mdo mdo merged commit e867fcf into twbs:v6-dev Mar 18, 2026
12 checks passed
mdo pushed a commit to pricop/bootstrap that referenced this pull request Mar 18, 2026
I've added a new section called **Complex** to the **Stepper** component to demonstrate how this component can be used in different scenarios.

This is possible as part of: twbs#42165
mdo added a commit that referenced this pull request Mar 18, 2026
* Added Complex section

I've added a new section called **Complex** to the **Stepper** component to demonstrate how this component can be used in different scenarios.

This is possible as part of: #42165

* Slight rephrase to match the rest of the docs

Slight rephrase to match the rest of the docs

* Updated the badge stepper

Updated the badge stepper to better illustrate how a "Complete" progress would work with multi-step "Complete" / "In-progress" / "Pending" statuses.

* Added vertical complex stepper example

Added vertical complex stepper example

* w-100 is not needed for vertical stepper

w-100 is not needed for vertical stepper

* Revamp

---------

Co-authored-by: Mark Otto <markdotto@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

2 participants