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

javascript - Is there a way to increase the border thickness of outlined buttons in material-ui? - Stack Overflow

programmeradmin3浏览0评论

I am making changes to a user interface designed with Material-UI ponents and I have been requested to make the borders of some outlined buttons wider. Is there a way I can acplish this using ponent props, themes, or styles?

This is the code for the two buttons I'm trying to draw along with the style and theme I'm currently using:

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>

This is how it looks as of right now: .jpg. I just want the border to be a tad thicker, and I'd appreciate the help. Thanks!

I am making changes to a user interface designed with Material-UI ponents and I have been requested to make the borders of some outlined buttons wider. Is there a way I can acplish this using ponent props, themes, or styles?

This is the code for the two buttons I'm trying to draw along with the style and theme I'm currently using:

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>

This is how it looks as of right now: https://i.sstatic/PnuAD.jpg. I just want the border to be a tad thicker, and I'd appreciate the help. Thanks!

Share Improve this question edited May 14, 2020 at 15:33 Dennis Vash 53.9k11 gold badges116 silver badges132 bronze badges asked Jun 17, 2019 at 14:12 Sam ZukSam Zuk 3891 gold badge3 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 12

Try: style={{ border: '2px solid' }} or throught 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>
    </>
  );
}

Demo:

发布评论

评论列表(0)

  1. 暂无评论