Ask Your Question
4

What is the method to alter the color of the disabled track in Mui <Slider>?

asked 2023-06-24 18:49:37 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-24 19:14:01 +0000

qstack gravatar image

One method to alter the color of the disabled track in Mui <slider> is to use the "overrides" property to target the ".MuiSlider-rail" and ".Mui-disabled" classes, and set the "backgroundColor" property to the desired color. Here is an example:

import Slider from '@material-ui/core/Slider';
import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles';

const theme = createMuiTheme({
  overrides: {
    MuiSlider: {
      rail: {
        '&.Mui-disabled': {
          backgroundColor: 'lightgray',
        },
      },
    },
  },
});

function MyComponent() {
  return (
    <ThemeProvider theme={theme}>
      <Slider disabled />
    </ThemeProvider>
  );
}

In this example, the disabled track of the Slider component will be colored with light gray. You can replace this value with any other valid CSS color value.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-24 18:49:37 +0000

Seen: 7 times

Last updated: Jun 24 '23