Search code examples
angularionic-frameworkionic4

Ionic4 - How to align alert buttion in center?


Just a quick fix but how do it center my buttons? I am using "alertCtrl.create"

1

also there does not seem to be some kind of centering in the alert ionic docs page.

https://ionicframework.com/docs/api/alert-controller

 alertCtrl.create ({  
    header: 'Invalid Input',
    message: 'Please enter correct details',
    buttons: ['Okay']
}).then(alertElement => alertElement.present());
    return;
}

Solution

  • use mode md to ios because `mode='ios' by default we have the buttons in center.

    alertCtrl.create ({  
        header: 'Invalid Input',
        mode:'ios', //by default you will get the button in center
        message: 'Please enter correct details',
        buttons: ['Okay']
    }).then(alertElement => alertElement.present());
        return;
    }