Wikimedia Developer Support

[OOUI MessageDialog] Adding a line-break into an OOUI MessageDialog

Is there a way to format text in an OOUI MessageDialog to accommodate line break? I’ve tried <br/>, \n and \n\n but these doesn’t work as expected.

Thanks for your guidance in advance!

1 Like

You could use an HtmlSnippet, something like:

mw.loader.using('oojs-ui-windows', function () {
    var messageDialog = new OO.ui.MessageDialog();
    OO.ui.getWindowManager().addWindows( [ messageDialog ] );
    OO.ui.getWindowManager().openWindow( messageDialog, {
        message: new OO.ui.HtmlSnippet("Message with<br>a line break.")
    } );
});
2 Likes

Thank you very much @samwilson. Your proposed solution works great!