How to create dialog, scale with text number.

Hi. I want to create dialog with title and text content.
But i need to scale with content(text).

ty for helping me.

Hi, There is an option in the details panel for Panels to use “Size to Content”

i tried it but i need to scale back ground too.
Like 1st image and 2nd image.