What API should I use to render a modal dialog?

In order to preserve styling consistency, I'd like to use the same modal dialog rendering library/API as the OOTB widgets use.

For example:

Is there any documentation or preferred method of doing this?

Thanks!