admin管理员组文章数量:1405127
I'm using the CircularProgress-Icon from Material ui. I want to change the following attributes:
- size
- color.
The relevant code looks like this:
const useStyles = makeStyles({
button: {
color: 'white',
fontSize: 15,
},
});
<CircularProgress className={classes.button} />
The color works fine, but the resizing doesn't work. I also tried "size: 15" and "height: 15, width: 15". But nothing works. Any suggestions why? Thanks a lot!!
I'm using the CircularProgress-Icon from Material ui. I want to change the following attributes:
- size
- color.
The relevant code looks like this:
const useStyles = makeStyles({
button: {
color: 'white',
fontSize: 15,
},
});
<CircularProgress className={classes.button} />
The color works fine, but the resizing doesn't work. I also tried "size: 15" and "height: 15, width: 15". But nothing works. Any suggestions why? Thanks a lot!!
Share Improve this question asked Apr 21, 2021 at 9:01 Ewax_DuEwax_Du 4652 gold badges14 silver badges26 bronze badges3 Answers
Reset to default 4I tried the size but its not working for me...so i did it like this.
const styles = {
activity: { height: 100, width: 100 },
};
const LoadingIndicator = (props) => {
return <CircularProgress style={styles.activity} {...props} />;
};
NEW
this works
<CircularProgress {...props} size={30} />
There is a kind of hacky way, which requires you to wrap your circularprogress with a fixed height/width div. Something like this :
const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
"& > * + *": {
marginLeft: theme.spacing(2)
},
width: 300,
height: 300
}
}));
export default function CircularIndeterminate() {
const [parentSize, setParentSize] = useState(0);
const parentRef = useRef(null);
useEffect(() => {
const { clientHeight, clientWidth } = parentRef.current;
setParentSize(Math.min(clientHeight, clientWidth));
}, []);
const classes = useStyles();
return (
<div className={classes.root} ref={parentRef}>
<CircularProgress size={0.8 * parentSize} />
</div>
);
}
You can play around with it here.
<HomeIcon fontSize="small" />
<HomeIcon />
<HomeIcon fontSize="large" />
<HomeIcon sx={{ fontSize: 40 }} />
Reference: https://mui./material-ui/icons/#size
<HomeIcon color="primary" />
<HomeIcon color="secondary" />
<HomeIcon color="success" />
<HomeIcon color="action" />
<HomeIcon color="disabled" />
<HomeIcon sx={{ color: pink[500] }} />
Reference: https://mui./material-ui/icons/#color
本文标签: javascriptHow to change size and color of a material ui iconStack Overflow
版权声明:本文标题:javascript - How to change size and color of a material ui icon? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744887192a2630557.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论