【问题标题】:Is there a way to increase the border thickness of outlined buttons in material-ui?有没有办法增加material-ui中轮廓按钮的边框厚度?
【发布时间】:2019-06-17 14:12:48
【问题描述】:

我正在对使用 Material-UI 组件设计的用户界面进行更改,并且有人要求我将一些轮廓按钮的边框加宽。有没有办法使用组件道具、主题或样式来实现这一点?

这是我尝试绘制的两个按钮的代码以及我当前使用的样式和主题:

const style = {
  play: {
    margin: 5,
    padding: 0,
    colorInherit: 'linear-gradient(45deg, #38e438 30%, #58e458 90%)',
  },
  play_disabled: {
    margin: 5,
    padding: 0,
    background: '#222',
  },
  clear: {
    margin: 5,
    marginRight: 10,
    padding: 0,
    background: 'linear-gradient(45deg, #FE3B3B 30%, #FF3B3B 90%)',
   },
  clear_disabled: {
    margin: 5,
    marginRight: 10,
    padding: 0,
    background: '#222',
  },
  default: {
    margin: 2,
    padding: 0,
    color: '#fff',
  },
  disabled: {
    margin: 2,  
    padding: 0,
    color: '#777',
  },
};
const theme = createMuiTheme({
  palette: {
    primary: {
      main: "#777",
    }
  }
});
<MuiThemeProvider theme={theme}>
  <Tooltip title="Render" placement="bottom-start">
    <Button
      id="play-btn"
      variant="outlined"
      size="small"
      onClick={this.handleRender}
      color="primary"
      className="header-btn"
      style={this.props.layoutType === layoutTypes.REFERENCE ? style.play_disabled : style.play}
      disabled={this.props.layoutType === layoutTypes.REFERENCE}>
      <Icon className="material-icons" style={{ color: '#777' }}>play_arrow</Icon>
    </Button>
  </Tooltip>
  <Tooltip title="Stop" placement="bottom-start">
    <Button
      id="stop-btn"
      variant="outlined"
      size="small"
      onClick={this.clear}
      color="primary"
      className="header-btn"
      style={this.props.layoutType === layoutTypes.REFERENCE ? style.clear_disabled : style.clear}
      disabled={this.props.layoutType === layoutTypes.REFERENCE}>
      <Icon className="material-icons" style={{ color: '#777' }}>stop</Icon>
    </Button>
  </Tooltip>
</MuiThemeProvider>

这是它现在的样子:https://imgur.com/C6Ar80r。我只是想让边框稍微厚一点,我会很感激你的帮助。谢谢!

【问题讨论】:

    标签: javascript reactjs material-ui


    【解决方案1】:

    尝试:style={{ border: '2px solid' }} 或通过makeStyles

    
    const useStyles = makeStyles(theme => ({
      button: {
        margin: theme.spacing(1),
        border: '2px solid'
      }
    }));
    
    function ThickerButton() {
      return (
        <>
          <Button
            variant="outlined"
            color="primary"
            style={{ border: '2px solid' }}
          >
            style
          </Button>
          <Button className={useStyles().button} variant="outlined" color="primary">
            makeStyles
          </Button>
        </>
      );
    }
    

    演示:

    【讨论】:

    • 非常适合我想要完成的工作!谢谢!
    猜你喜欢
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-16
    • 1970-01-01
    • 2016-11-18
    相关资源
    最近更新 更多