Ionic 2 Alert customization

后端 未结 5 1345
有刺的猬
有刺的猬 2020-12-18 14:06

I want to customize my alerts in Ionic 2. I know that I can do it globally in the variables.scss, but I want to modify a specific one, in a specific page.

I tried cs

5条回答
  •  执念已碎
    2020-12-18 14:36

    Edit all your AlertController.create methods to look like this:

    const alert = this.alertCtrl.create({
        title: title,
        subTitle: msg,
        buttons: ['OK'],
        cssClass: 'alertCustomCss' // <- added this
    });
    

    And add this to app.scss:

    .alertCustomCss {
        // text color for basic alerts
        color: white; 
    
        // alert modal page bg color. Warning this will remove the alert transparency
        background-color: color($colors, dark, base); 
    
        button {
            color: white !important; // button text color
            background-color: color($colors, secondary, base) !important;
                //button bg color
        }
    
        .alert-message {
            color: white; // text color for confirm alerts
        }
    
        .alert-wrapper {
            background-color: color($colors, dark, base); // bg color of alert content
        }
      }
    

提交回复
热议问题