Chase AdamsChase Adams
AboutContentPromptsPlayground

Styling the MUI Linear Progress Bar

Essays and updates on product, engineering, and AI by Chase Adams.

1 minute read

Styling the MUI Linear Progress Bar React component is incredibly confusing when you want to change both the colors of the whole bar and the foreground of the bar, even with the LinearProgressAPI handy.

In order to get this working, I ended up styling the root element with the &.${linearProgressClasses.determinate} and to style the progress indicator color, I styled the bar1Determinate (&.${linearProgressClasses.determinate} > .${linearProgressClasses.bar1Determinate}).

In this example I used styled-components but this would work with any style library that exports a styled function that takes an element or react component.

import LinearProgress, {
  linearProgressClasses
} from "@mui/material/LinearProgress";

import styled from "styled-components";

  

const StyledLinearProgressBar = styled(LinearProgress)({
	[`&.${linearProgressClasses.determinate}`]: { backgroundColor: "#f0f" },
	[`&.${linearProgressClasses.determinate} > .${linearProgressClasses.bar1Determinate}`]: { backgroundColor: "#0ff" }
});

You can see this in action in this CodeSandbox

First Cohort
No Coding Experience Required

Build Your Website with AI—No Code Required

Learn to create and deploy professional websites using ChatGPT and Claude. Go from complete beginner to confident website builder.

Start Building Today

Post Details

Published
Jan 12, 2023
Category
Engineering
Share
Ask ChatGPT
Ask Claude

Latest Posts

Joining Rocket Money as VP of AI Engineering

Joining Rocket Money as VP of AI Engineering

Leading AI engineering at Rocket Money to write the playbook for how engineering teams operate in the AI era

AboutAI Workflow SpecContentStacksNewsletterPromptsRSS

Ask me anything

Loading...

Hi! Ask me anything about Chase's work.

I can answer questions based on his blog posts and articles.

Experimental: This chat is a side project I work on in my free time. Responses may vary in quality and accuracy.