最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to change the color of the placeholder in material UI React js - Stack Overflow

programmeradmin0浏览0评论

How do I change the color of the background and the flashing color of the Skeleton ponent in Material UI ?

I'm trying to set custom styling for them as shown below:

<Skeleton variant="circle" classes={{root:'placeholder-animation'}} animation="wave" width={56} height={56} />
.placeholder-animation{
    background: chartreuse;
}

How do I change the color of the background and the flashing color of the Skeleton ponent in Material UI ?

I'm trying to set custom styling for them as shown below:

<Skeleton variant="circle" classes={{root:'placeholder-animation'}} animation="wave" width={56} height={56} />
.placeholder-animation{
    background: chartreuse;
}
Share Improve this question edited May 21, 2021 at 3:58 crg 4,5783 gold badges38 silver badges68 bronze badges asked May 20, 2021 at 18:55 Aadhit ShanmugamAadhit Shanmugam 5193 gold badges14 silver badges25 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

Material-ui use makeStyles to override styles with global class names.

Reading the Material-ui doc, it seems that tou have more than one way to go.

You could use makeStyles to override styles with global class names.

const useStyles = makeStyles({
  root: {
    background: red,
  }
});

... 

<Skeleton variant="circle" classes={{root: classes.root}} animation="wave" width={56} height={56} />

Or you could simply use className

<Skeleton variant="circle" className="placeholder-animation" animation="wave" width={56} height={56} />
.placeholder-animation{
    background: chartreuse;
}
sx={{"&::after":{background: `linear-gradient( 90deg, transparent, #B4AFA5, transparent)`}}}

You don't need any class to change color of placeholder you can use sudo selector to change color of placeholder check this

::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
  color: red;
  opacity: 1; /* Firefox */
}

:-ms-input-placeholder { /* Internet Explorer 10-11 */
  color: red;
}

::-ms-input-placeholder { /* Microsoft Edge */
  color: red;
}

here is working example

::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
  color: red;
  opacity: 1; /* Firefox */
}
<input type="text" placeholder="Write somthing.">

发布评论

评论列表(0)

  1. 暂无评论