Jetpack Compose Alertdialog Increase Spacing Between Title and Content

Padding in text doesn't add to the spacing, so I discard the use of title and load a custom title in text instead.

AlertDialog(    modifier = Modifier.fillMaxWidth(),    onDismissRequest = {        onDismiss()    },    /*    // discard title usage    title = {       if (!title.isNullOrEmpty()) {           Text(title)       }    },     */    text = {        Column (            modifier = Modifier                .fillMaxWidth()                .padding(8.dp),            // horizontalAlignment = Alignment.CenterHorizontally        ) {            // create custom title            if (!title.isNullOrEmpty()) {                Text(title,                    modifier = Modifier.padding(vertical = 8.dp),                    style = MaterialTheme.typography.subtitle1)            }            ProgressBar(modifier = Modifier                .height(16.dp)                .fillMaxWidth(), progress = progress)        }    },    buttons = { })

NOTE: Stefano mentioned this problem is solved in Material 3, but I have yet to try it.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.