How can I modify the color of the angular stepper progress bar when the next step is active

I'm attempting to create a progress stepper similar to the one shown in this image: https://i.sstatic.net/jzT0i.png

Below is my CSS code:

.mat-step-header[aria-selected="true"] {
    background-color: #07C496;
}
.mat-step-header[ng-reflect-active='true']{
    background-color: #07C496;
 }

HTML:

<mat-horizontal-stepper #stepper labelPosition="bottom" linear >
    <ng-template matStepperIcon="edit" let-index="index"> {{index + 1}}
    </ng-template>
    <mat-step>
        <ng-template matStepLabel>test</ng-template>
        <div>
    </mat-step>
<mat-step>
        <ng-template matStepLabel>test</ng-template>
        <div>
    </mat-step>
<mat-step>
        <ng-template matStepLabel>test</ng-template>
        <div>
    </mat-step>
<mat-step>
        <ng-template matStepLabel>test</ng-template>
        <div>
    </mat-step>
</mat-horizontal-stepper>

This setup works in development mode but not in production mode because `ng-reflect-active` doesn't exist. I need help achieving this using only CSS. Thank you.

Answer №1

To achieve a similar effect as "select all elements before", you can use the general sibling combinator (~) in CSS:

.mat-step-header {
    background-color: #07C496 !important;
}

.mat-step-header[aria-selected="true"] ~ * {
    background-color: transparent !important;
}

Check out this Stackblitz Example for reference.

Answer №2

.modified-mat-stepper-horizontal-line,
.modified-mat-horizontal-stepper-header::after,
.modified-mat-horizontal-stepper-header::before {
  top: 27px !important;
  border-top-width: 5px !important;
  transition: background-color 0.3s ease, width 0.3s ease;
}
.modified-mat-step-header[ng-reflect-state="done"]::after,
.modified-mat-step-header[ng-reflect-state="done"]+ .modified-mat-step-header[ng-reflect-state="done"]::before {
  background: green !important;
  transition: background-color 0.5s ease, width 0.5s ease; 
}
.modified-mat-step-header[ng-reflect-state="done"] + .modified-mat-stepper-horizontal-line {
  background: green;
  transition: background-color 0.5s ease; 
}
.modified-mat-step-header[ng-reflect-selected="true"]::before,.modified-mat-step-header[ng-reflect-state="done"]::before{
  background: green;
}
Angular 15
Make sure to review this code for assistance

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to access an angular route directly through the browser?

Hello, I'm encountering some difficulties with Express rendering certain routes. When I go to the website example.com, everything functions correctly. However, when I try to access a route like example.com/login, I receive an error stating Cannot get ...

Having trouble getting tsserver-plugins to function properly in either Atom or VSC

My team and I are on a mission to enhance our Angular 2 templates with code completion, similar to what is showcased in this gif. To achieve this goal, we require: tsserver-plugins coupled with tslint-language-service and @angular/language-service We ...

Is there a way to ensure that the div of my template spans 100% in width and height?

I'm attempting to make my div 100% in size but I am having trouble achieving it. Here is my code: <template> <div> <Navbar/> <Calendar/> </div> </template> <script setup> import Calendar from &apos ...

Broadcasting events across the entire system

I'm trying to accomplish something specific in Angular2 - emitting a custom event globally and having multiple components listen to it, not just following the parent-child pattern. Within my event source component, I have: export class EventSourceCo ...

the best way to ensure thumbnails are perfectly centered across all screen sizes

body{ width:auto; color:white; font-size:15px; width:100%; max-width:1980px; min-width:334px; margin:0px auto; } I have been struggling to center thumbnails on my webpage for all screen resolutions. I've tried using th ...

An error with rendering in Internet Explorer 8

When I hide a td in a table by setting its display to none, the table does not resize correctly when using IE8. If I have a table and want to remove an entire column, I might try something like this: $("th:first, th:last, tr td:first-child, tr td:last-ch ...

Specifying the type of "this" within the function body

After going through the typescript documentation, I came across an example that explains how to use type with this in a callback function. I am hoping someone can assist me in comprehending how this callback will operate. interface DB { filterUsers(fil ...

Position a dynamically generated cell in the middle of the window

I am currently developing an employee directory that allows users to search for a specific employee and view their information in a tree or org-chart layout. To achieve this, I have implemented the Google Org Chart code for generating the chart. Each emplo ...

The Highcharts Angular Chart fails to update after the renderer.button event is triggered

Within the chart interface, you'll find two unique buttons designed to facilitate the updating of the series and redrawing of the chart based on user preference. One allows for toggling views by percentage, while the other does so by count. When the c ...

At which point during the lifecycle of an Angular application should the JWT token be refreshed

As a new Angular user, I am uncertain about where to refresh an access token. I am familiar with guards and interceptors, but I need guidance on the best approach and any potential trade-offs. Many tutorials cover the "how" but lack insights into the "why" ...

Difficulty with setting up a basic Angular 5 environment

I am facing difficulties in setting up and running Angular5 on my system. Here are the steps I followed in my home directory: $ sudo npm install @angular/cli -g $ ng new my-verbsandvocab $ cd my-verbsandvocab $ ng serve However, I encountered an erro ...

What are the steps to utilize dismissableMask feature in PrimeNG?

Trying to hide a dialog by clicking outside of it seems tricky with PrimeNG's dismissableMask. Does anyone have a solution for this? HTML Code <button type="text" (click)="showDialog()" pButton icon="fa-external-link-square" label="Show"></ ...

What is the correct way to properly parse JSON attributes containing slashes?

I have 2 Custom Interfaces: DataModel.ts export interface Entry{ id: number, content: Note } export interface Note{ message: string } These interfaces are utilized in typing the HttpClient get request to fetch an array of Entries: DataService.ts getE ...

Jest encounters issues while attempting to execute TypeScript test cases

Encountering an error while trying to execute tests in a repository that has a dual client / server setup. The error seems persistent and I'm unable to move past it. > jest --debug { "configs": [ { "automock": false, ...

The inability for two dynamically created Ajax elements to identify one another is hindering their interaction

Hello wonderful people at Stack Overflow, I've been attempting to create a table generator that dynamically creates two tables upon the click of a button. So far, it's been quite a frustrating journey full of roadblocks... Currently, my approac ...

Steps for positioning a div with list items to match the height of its parent container

I've been grappling with this problem for a long time now. Within the parent div "wrapper," there is a child div called "sidebar-wrapper" that contains an ul with li elements. I'm trying to make the height of "sidebar-wrapper" adjust to match t ...

What is the best method for accessing a single product by its unique ID parameter in MongoDB?

Seeking assistance in retrieving specific product details by id from MongoDB via params. While able to fetch all products, unsure how to retrieve the details of a single product upon selection. Any advice is appreciated. API.js router.route('/product ...

Ways to stop the side navbar from scrolling

Instead of having a separate scroll for the side navbar, I would prefer to have it scroll along with the main body. This way, when you scroll through the main content, the additional side navbar information will also be displayed. For an example, you can ...

Border for status input like on Facebook

I tried to investigate with Firebug, but struggled to find a solution. How does Facebook wrap the border around the autosize input in the status section? I am particularly curious about the small triangle attached to the border. While using Firebug, I loca ...

Avoiding the sudden appearance of unstyled content in Single-File Components

I am looking to update my HTML navigation <div id="header-wrapper"> <div id="header-logo-title"> <nav> <ul id='mainNav'> <li>Home</li> </ul> </nav> ...