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 is the most efficient method of storing Formik values in Redux Toolkit to ensure persistence using redux-persist?

I have created a multi-step form using React, Formik, Redux Toolkit, and redux-persist. The form steps are currently saved in the Redux state, allowing users to resume from where they left off even if they close or reopen the window. However, I am now faci ...

Introducing a new feature in React-Select: enabling copy-paste functionality for the multi-select text

Incorporating a react-select component (specifically generated using CreatableSelect) into my project has been quite beneficial. This multi select text input feature allows users to conveniently add keywords as options. While the current functionality is ...

Angular 5 Directive for Structuring Content

I'm currently in the process of developing a versatile search box component, with the following setup: search.component.html <div class="search-box-container"> <fa-icon class="search-icon" [icon]="faSearch"></fa-icon> <input ...

Height that is determined in real-time

I am attempting to adjust the height of a div based on the size of the screen. Within this div, there is a calendar that contains multiple lines of content, which can be displayed or hidden based on user preference. The height of the calendar is not fixed, ...

What could be the reason for justify-self: flex-start not positioning the div at the bottom of a column?

I want to display a div in three levels: header, content, and footer. The content can vary in height and the footer should always be at the bottom. Here is how I have implemented it: <div class="news-content-block"> <div class=" ...

What is the best way to remove the hover effect from a specific element within a div?

I am looking to achieve a specific hover effect where the white part does not darken when hovering over a certain element within its child elements. Here is the HTML code I have: <div className= {css.searchBarDiv}> <div className={css.searchBar ...

Parent div overflowing due to vertical flex container

In my current project, I am attempting to design a layout with a fixed header and footer along with a dynamic content area that utilizes the remaining vertical space. The content-wrapper contains a lot of data, which may require a scrollbar to navigate. H ...

Why am I encountering numerous errors while attempting to install Juice Shop?

My attempt to install the juice shop app from GitHub resulted in 63 errors showing up after running the command npm install. [riki@anarchy]: ~/juiceShop/juice-shop>$ npm install (Various warnings and engine compatibility issues) Multiple vulnerabilit ...

Creating visually appealing Jquery-ui tab designs

Trying to customize the jquery tabs, I experimented with styling them to my liking. One thing I did was attempt to reduce the size of the tabs by adding a height:45px; to the UI stylesheet shown below. .ui-tabs-vertical .ui-tabs-nav li { clear: left; ...

What is the best way to place an icon in the center of a Bootstrap 5 card image?

I'm looking to center an icon within a bootstrap-5 card image. I have an icon that I want to display at the center of my card image, but I'm unsure how to achieve this using either CSS or Bootstrap-5. Can anyone provide guidance on how to accompl ...

Why does TypeScript struggle to accurately deduce the return type when provided with certain parameter values?

I have a function that uses a switch case to return different results depending on the input. The function, called "getTimeAgo," takes in two parameters: "date" (which can be either a Date object or a string) and "mode" (which can only be either "days" or ...

The IDE is showing an error, but Jest is able to run it flawlessly

I recently created a Jest unit test for a TypeScript function called checkEmail, which internally uses showAlert. The showAlert function in the utils.ts file looks like this: export const showAlert = (message: string) => { toast(message); }; In my ...

I am looking to include a popover within my modal using Bootstrap version 3.0.2

Hey there, I'm having an issue where the popover that should be inside the modal is actually appearing outside of it in the top left corner, not visible within the modal itself. Below is my index code: <button type="button" id="example" class="bt ...

Steps for modifying the CSS style of a div element following an onclick event:

<html> <head> <style type="text/css"> .step_box { border: 1.0px solid rgb(204, 204, 204); border-radius: 10.0px 10.0px 10.0px 10.0px; } .step_box:hover{ background: rgb(184, 225, 252); } .selected { background-color : #fff000; ...

Create a versatile notification system that can be used throughout a React application

Currently, I am working on enhancing a React application by utilizing react-redux and redux-thunk for integrating with redux to manage the state. One of my goals is to have a modal popup whenever a new entity is added. The solution that appeals to me invo ...

Trouble with Setting a Background Image in Ionic with Javascript and Angular

I'm having trouble getting my background image to display in this Ionic project using CSS. It works when I embed it directly into the HTML, but that's not an ideal solution. I vaguely recall something about using base64 for images, but I'm n ...

Sending a series of data values through a REST API endpoint

Currently, I am utilizing the Slim framework to develop a REST API for an ongoing project. The front end of the application is built using ReactJS. There is one particular issue that I am grappling with at the moment - within my ReactJS App, I have a coll ...

Nexus and GraphQL: The root typing path for the "context" type is not found

I’m currently working on integrating GraphQL into Next.js API routes. For writing the GraphQL schema, I’m utilizing Nexus. Here are the two essential files: context.ts and schema.ts, that help in setting up Nexus development mode. // context.ts import ...

The static method in TypeScript is unable to locate the name "interface"

Is it possible to use an interface from a static method? I'm encountering an issue and could really use some help. I've been experimenting with TypeScript, testing out an interface: interface HelloWorldTS { name : string; } Here&ap ...

Evaluate redux-actions

Is there a way to effectively test React-redux actions using Jest? import { combineReducers } from 'redux'; import { handleActions } from 'redux-actions'; import * as actions from '../actions/index'; const background = handle ...