如何设置材质ui图标的样式

时间:2020-10-09 09:56:55

标签: reactjs material-ui

如何将材质ui图标居中放置在按钮中?

import AddIcon from '@material-ui/icons/Add';
 <Button><AddIcon style={{ bottom: 3, right: 3 }}/>ADD</Button>

enter image description here

2 个答案:

答案 0 :(得分:0)

有一种特殊类型的按钮,称为带有图标和标签的按钮

您可以详细了解here

答案 1 :(得分:0)

要将自定义样式添加到Material ui,您需要makeStyles

示例

import React from 'react';
import { makeStyles } from '@material-ui/core/styles';

...

const useStyles = makeStyles({
  root: {
    background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
    borderRadius: 3,
    border: 0,
    color: 'white',
    height: 48,
    padding: '0 30px',
    boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
  },
  label: {
    textTransform: 'capitalize',
  },
});

...

const classes = useStyles();

  return (
    <AddIcon
      classes={{
        root: classes.root,
        label: classes.label,
      }}
    >