1

When I used Material-UI slider and customized it, I found on the doc this piece of code for styling :

const AirbnbSlider = withStyles({
  root: {
    color: '#3a8589',
    height: 3,
    padding: '13px 0',
  },
  thumb: {
    height: 27,
    width: 27,
    backgroundColor: '#fff',
    border: '1px solid currentColor',
    marginTop: -12,
    marginLeft: -13,
    boxShadow: '#ebebeb 0 2px 2px',
    '&:focus, &:hover, &$active': {
      boxShadow: '#ccc 0 2px 3px 1px',
    },
    '& .bar': {
      // display: inline-block !important;
      height: 9,
      width: 1,
      backgroundColor: 'currentColor',
      marginLeft: 1,
      marginRight: 1,
    },
  },
  active: {},
  track: {
    height: 3,
  },
  rail: {
    color: '#d8d8d8',
    opacity: 1,
    height: 3,
  },
})(Slider);

I thought this was a typo at first, but by looking at the MUI source, there were a few times when &$active is used, and not &:active. I was wondering what it does, as I don't find any use of $ in CSS, and found no variables relative to this $active state.

What's the difference between &:active and &$active here ?

Thanks for your time!

Shirin
  • 11
  • 1
  • `$` is a refrence used to refer parent rule. ryan-cogswell has explained this very well here:- https://stackoverflow.com/a/59251768/11222282 For last part of your question, `&:active` is used to style the active state of links whereas `&$active` is used to style the active rule of the slider – Rajiv Nov 08 '20 at 08:33
  • https://material-ui.com/customization/components/#use-rulename-to-reference-a-local-rule-within-the-same-style-sheet check this. Material-ui official statement – Rajiv Nov 08 '20 at 08:42
  • your welcom!! :D – Rajiv Nov 09 '20 at 03:29

0 Answers0