You wouldn’t want the dialog to match the length of the sentence and exceed the width of the display.
The UI.messagebox
is a very simple method that you can call, with content but not modify a lot. To configure more, you would better get hold of an object reference.
When you create a HtmlDialog, you have such an object where you can configure properties before calling it to be shown.
See here for a minimal messagebox-like example.