使用SweetAlerts 2自定义按钮

问题描述 投票:0回答:3

我需要匹配给我的定制设计。我目前正在使用SweetAlerts 2进行所有对话框的确认和取消。我需要取消按钮,以白色背景和青色彩色文字和蓝绿色边框。两个按钮的边界也需要半径为25px。

我在文档中找不到任何可以执行这些操作的参数。我也找不到任何其他资源来完成此任务。

  // Delete click
  handleDeleteClick = () => {
    // Warning alert before delete
    Swal({
      title: 'Are you sure you want to delete this item?',
      type: 'warning',
      reverseButtons: true,
      showCancelButton: true,
      confirmButtonColor: '#4DB6AC',
      cancelButtonColor: 'white',
      confirmButtonText: 'Delete',
    }).then((result) => {
      if (result.value) {
        // Delete task
        axios.delete(`/api/goals/tasks/${this.props.task.id}`)
          .then(this.handleDeleteClickSuccess)
          .catch(this.handleDeleteClickError);
      }
    });
  }

我需要取消按钮,以白色背景和青色彩色文字和蓝绿色边框。两个按钮的边界也需要半径为25px。

编辑:

/* Material UI styling */
const styles = theme => ({
  heading: {
    backgroundColor: '#E3E3E3',
    border: '1px solid #cccccc',
  },
  buttonsRight: {
    justifyContent: 'flex-end',
  },
});
javascript reactjs material-ui sweetalert2
3个回答
0
投票

可以通过使用其他样式覆盖CSS类的属性来检查按钮并更改样式

.swal-button--cancel {
  // your css
}

0
投票

您可以更改只需更改项目中的SASS变量。

https://github.com/sweetalert2/sweetalert2/blob/master/src/variables.scss


0
投票

捂脸。我将使用材料ui对话框

© www.soinside.com 2019 - 2024. All rights reserved.