The CSS "mask" property is experiencing compatibility issues on Google Chrome

Hey there! I've recently developed a unique progress bar component in React that showcases a stunning gradient background. This effect is achieved by utilizing the CSS mask property. While everything runs smoothly on Firefox, I'm facing a slight hiccup when it comes to Chrome.

For some reason, the mask doesn't quite apply as expected on Chrome unless I trigger a rerender by tweaking the browser size or toggling the mask property off and back on again.

Oddly enough, this issue only seems to occur on CodeSandbox and not here on Stack Overflow:

CodeSandbox Progress Bar

    function increaseWidthUntil100Percent(element, currentWidth = 0) {
      if (currentWidth < 100) {
        const newWidth = currentWidth + 5;
        element.style.width = `${newWidth}%`;

        setTimeout(() => {
          increaseWidthUntil100Percent(element, newWidth);
        }, 1000);
      }
    }

    const myDiv = document.getElementById('bar');
    increaseWidthUntil100Percent(myDiv);
.progress-bar {
  height: 0.5rem;
  border-radius: 3rem;
  background-color: #c0c6df;
  padding: 0.25rem;
  width: 100%;
  position: relative;
}

.progress-bar > .progress-bar__bar::before {
  content: "";
  border-radius: 3rem;
  background: linear-gradient(
    90deg,
    rgba(209, 107, 165, 1) 0%,
    rgba(132, 166, 228, 1) 50%,
    rgba(1, 22, 42, 1) 100%
  );
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.progress-bar > .progress-bar__bar {
  height: 100%;
  border-radius: 3rem;
  -webkit-mask: linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0);
  transition: 0.3s ease;
}
<div class="progress-bar">
  <div id="bar" style="width: 0" class="progress-bar__bar"></div>
</div>

Your assistance with this matter is greatly appreciated!

Answer №1

Inserting

{
  display: block;
}

into the .loading-indicator__spinner class might solve the issue. It's strange how it only kicks in after resizing the window, but hey, whatever works!

Answer №2

Not certain if this approach will resolve your problem, but here's an alternative method utilizing clip-path and CSS variables

function expandWidthTo100Percent(element, currentWidth = 0) {
      if (currentWidth < 100) {
        const newWidth = currentWidth + 5;
        element.style.setProperty('--w',`${newWidth}%`);

        setTimeout(() => {
          expandWidthTo100Percent(element, newWidth);
        }, 1000);
      }
    }

    const targetDiv = document.getElementById('bar');
    expandWidthTo100Percent(targetDiv);
.progress-bar {
  height: 0.5rem;
  border-radius: 3rem;
  background-color: #c0c6df;
  padding: 0.25rem;
  display: grid;
}

.progress-bar > .progress-bar__bar {
  background: linear-gradient(
    90deg,
    rgba(209, 107, 165, 1) 0%,
    rgba(132, 166, 228, 1) 50%,
    rgba(1, 22, 42, 1) 100%
  );
  transition: 0.3s ease;
  clip-path:inset(0 calc(100% - var(--w,0%)) 0 0 round 3rem);
}
<div class="progress-bar">
  <div id="bar" class="progress-bar__bar"></div>
</div>

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 causes the Material-UI Grid element to shift upon clicking it?

I have encountered an issue while developing a React app with Material UI. The problem arises on a specific page of the application. This particular page consists of text and a button aligned vertically, along with a second set of text and another button ...

What is the best way to include an item in a list with a specific identifier using the useState Record data type in a React application built with TypeScript?

Here is the structure of my Record type: const PEOPLE_MAP_INIT: Record<string, Person[]> = { "1": [], "2": [], "3": [] }; I have initialized the useState like this: const [PEOPLE_MAP, SET_PEO ...

Is there a way for me to position my menu on the right side of my website?

I am currently working on a gallery website and facing an issue with the menu placement. I want to position the menu items on the right side of the images, but they keep appearing at the bottom instead. Despite adjusting the width in classes like galleryme ...

What steps should I take to address the issue of sanitizing a potentially harmful URL value that contains a

I've encountered a URL sanitization error in Angular and despite researching various solutions, I have been unable to implement any of them successfully in my specific case. Hence, I am reaching out for assistance. Below is the function causing the i ...

Only map property type when the type is a union type

My goal is to create a mapping between the keys of an object type and another object, following these rules: Each key should be from the original type If the value's type is a union type, it should have { enum: Array } If the value's type is not ...

The React Camera component experiences issues when trying to function on a mobile device

I've been trying to test the Camera functionality in my React application using different mobile devices like the iPad Pro and Google Pixel 6a. I experimented with both react-webcam and react-camera-pro, but unfortunately, neither seemed to work on mo ...

My website always fits on smaller resolution screens, but annoyingly, a horizontal scroll bar still appears

My website seems to have a horizontal scroll bar on smaller resolution screens, even though it fits. Any suggestions on making it fit better? If you're using a laptop, you'll notice that the scroll bar moves too far right to just show blank grey ...

What steps should I take to fix this Angular 8 error?

Encountered an issue in ../node_modules/@angular/http/src/backends/jsonp_backend.d.ts:1:28 - error TS2307: Module 'rxjs/Observable' not found. 1 import { Observable } from 'rxjs/Observable'; ~~~~~~~~~ ...

What is the best way to assign a unique background color to each individual card in my card list?

I have a list of cards and I want to assign a unique color to each card in the list. I attempted to do this on my own, but it ended up being more complex than I anticipated. Here is the list of cards: return ( <Container> <Row className=&qu ...

Why is it not possible for me to choose an element after it has been placed within a grid component?

Struggling to eliminate the blur effect on an image inside a grid element? It seems modifying the properties of an element within a grid class is causing some issues. To simplify, I conducted a basic test: I managed to change the ppp2 class when hovering ...

The issue with the Shadcn dialog not closing when the submit button is pressed

I am currently utilizing the shadcn dialog component, and I made some adjustments to its default behavior. Initially, the submit button was functional even without any input in the fields, which was not my intended functionality. Now, the submit button no ...

Centered HTML Columns on the Screen

Figuring out this simple html + css issue is proving to be quite challenging for me. I am attempting to create a '3 column' layout. I envision a central column (approximately 10em in width) with two additional columns flanking it on each side (e ...

What is the best way to exclude the bottom four rows when sorting with MatSort?

Is there a way for me to keep the last four rows fixed when sorting the table based on the column header? Here is an image of the table: table image <table mat-table [dataSource]="dataSourceMD" matSort (matSortChange)="getRowMaximoTable( ...

Images in the JavaScript menu are not remaining fixed in place

Can someone help me with my website? I'm having trouble with the menu for different pages, it should stay gray for the active page. It was working fine before I switched to Wordpress, but now I'm not sure what the issue is. Could someone take a ...

What is the best way to solve the problem of Chrome auto-complete overlapping with labels in Vuetify?

When attempting to make a login form using outlined text fields in Vutify, there is an issue with Chrome autocomplete overlapping the labels. <v-text-field v-model="email" label="e-mail" name="email" outlined prep ...

I'm not satisfied with the value of the ReactJs state after the change

I am working on creating a calendar app for practice purposes. Currently, I have a current_month state variable set to 1. Additionally, I have a function called IncreaseMonth() that is designed to increment the value of current_month. However, when the va ...

What could be the reason for typescript not issuing a warning regarding the return type in this specific function?

For instance, there is an onClick event handler attached to a <div> element. The handler function is supposed to return a value of type React.MouseEventHandler<HTMLDivElement> | undefined. Surprisingly, even if I return a boolean value of fal ...

A guide to managing Ajax in functional components in React without using classes

Currently, I am striving to develop all my components as pure functions. However, I have encountered an issue. The component I am working on resembles the structure below. The problem arises when the result of an ajax request triggers a rerender, leading ...

Guide to utilizing custom fonts in a VUE application

I'm currently working on my first Vue project and despite following various examples and the official documentation, I am struggling to resolve an issue regarding importing fonts locally in my project. Within my `` tag, I am importing the font that I ...

Substitute all instances of null bytes

I need to remove null bytes from a string. However, after replacing the null bytes \u0000 in the string let data = {"tet":HelloWorld.\u0000\u0000\u0000\u0000"} let test = JSON.parse(data).tet.replace("\u0000", ""); I always ...