UX4G Logo
Components

Modal Dialog

Focus-trapping modal dialog featuring standard alerts, hero image banners, customizable avatars, icons, and flexible button footers

The UX4G Modal Dialog component displays high-priority information, confirmation prompts, destructive action safeguards, or multi-step decisions overlaying the main application interface.

It supports:

  • Header Variants: Standard left-aligned/centered titles, leading icons, circular avatars, or image thumbnails.
  • Hero Image Banners: Full-bleed edge-to-edge banners or padded rounded cards.
  • Content Flexibility: Subtitles, rich body copy, or custom composable slots with customizable divider lines.
  • Footer Buttons: Single or double action buttons with left, right, center, or split alignments and optional leading helper icons.

Import from com.ux4g.designsystemv1.components.modal.*.


Interactive Previews

1. Default Modal

Standard dialog with a title header, close icon, subtitle, body text, and two right-aligned footer action buttons.

Ux4gModal (Default Variant)Jetpack Compose
UX4G Default Modal Preview

2. Hero Image Modal

Prominent modal with a top full-bleed colored hero banner, leading category icon, description subtitle, body copy, and dual action buttons.

Ux4gModal (Hero Image Variant)Jetpack Compose
UX4G Hero Image Modal Preview

Kotlin Usage

Citizen Confirmation Dialog Example
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.modal.*
import com.ux4g.designsystemv1.components.buttons.Ux4gButton
import com.ux4g.designsystemv1.foundation.Ux4gIcons

@Composable
fun CitizenApplicationScreen() {
    var showConfirmModal by remember { mutableStateOf(false) }

    Ux4gButton(
        text = "Submit Scheme Application",
        onClick = { showConfirmModal = true }
    )

    if (showConfirmModal) {
        Ux4gModal(
            onDismiss = { showConfirmModal = false },
            headerTitle = "Confirm Final Submission",
            leadingItem = Ux4gModalLeadingItem.Icon,
            leadingIcon = Ux4gIcons.Info,
            showSubtitle = true,
            subtitleText = "Application Review",
            showBody = true,
            bodyText = "Are you sure you want to finalize and submit this application? Once submitted, form details cannot be modified.",
            footerButtons = Ux4gModalFooterButtons.TwoButtons,
            footerAlign = Ux4gModalFooterAlign.Right,
            primaryButtonText = "Yes, Submit",
            secondaryButtonText = "Cancel",
            onPrimaryClick = {
                // Execute API call
                showConfirmModal = false
            },
            onSecondaryClick = { showConfirmModal = false }
        )
    }
}

Parameters

Ux4gModal Props

PropTypeDescriptionDefault
onDismiss *() -> UnitCallback invoked when citizen dismisses dialog by clicking backdrop, back press, or close icon.—
modifierModifierCompose layout modifier.Modifier
headerImageUrlString?Remote image URL for the top hero banner.null
headerImageContent(@Composable () -> Unit)?Custom composable slot for the top hero banner (e.g. gradient background).null
headerImageHeightDpHeight of the top hero image area.160.dp
headerImageStyleUx4gModalHeaderImageHero image style: FullBleed, Padded, or None.Ux4gModalHeaderImage.FullBleed
leadingItemUx4gModalLeadingItemHeader leading element: None, Icon, Avatar, or Image.Ux4gModalLeadingItem.None
leadingIconUx4gIconIcon rendered when leadingItem = Ux4gModalLeadingItem.Icon.Ux4gIcons.info_circle
leadingIconTintColor?Custom color tint for the leading icon.null
avatarInitialsString?Initials string rendered when leadingItem = Ux4gModalLeadingItem.Avatar.null
avatarImageUrlAny?Image URL or resource for avatar.null
avatarIconUx4gIcon?Fallback icon for avatar.null
showHeaderBooleanControls visibility of the header section.true
headerTitleStringMain title text displayed in the header."Header"
showDescriptionBooleanControls visibility of the description text below header title.false
descriptionTextStringDescription text content below header title."Write description here"
showDividersBooleanRenders divider lines separating header, body, and footer.true
showSubtitleBooleanControls visibility of the subtitle heading inside body.true
subtitleTextStringSubtitle text content."Subtitle"
showBodyBooleanControls visibility of the main body content.true
bodyTextStringParagraph text in the body area."A modal is a design element..."
bodyContent(@Composable () -> Unit)?Custom composable slot replacing standard bodyText.null
showFooterBooleanControls visibility of the footer actions section.true
footerButtonsUx4gModalFooterButtonsButton layout: OneButton, TwoButtons, OneButtonWithIcon, or TwoButtonsWithIcon.Ux4gModalFooterButtons.TwoButtons
footerAlignUx4gModalFooterAlignAlignment of buttons: Left, Right, Center, or Split.Ux4gModalFooterAlign.Right
isDestructiveBooleanWhen true, renders primary button in destructive error red tone.false
primaryButtonTextStringLabel for the primary filled action button."Button"
secondaryButtonTextStringLabel for the secondary outline button."Button"
leadingActionIconUx4gIconIcon for footer leading auxiliary button.Ux4gIcons.info_circle
onPrimaryClick(() -> Unit)?Click callback for the primary button. Defaults to onDismiss.null
onSecondaryClick(() -> Unit)?Click callback for the secondary button. Defaults to onDismiss.null
onLeadingIconClick(() -> Unit)?Click callback for the footer leading icon button.null
alignmentUx4gModalAlignmentContent alignment: LeftAligned or Centered.Ux4gModalAlignment.LeftAligned
showCloseButtonBooleanWhether to display the top-right close icon button.true
backgroundColorColor?Modal card background color.Ux4gColors.white
cornerRadiusDpCorner radius of the modal dialog card.16.dp

Enums Reference

enum class Ux4gModalAlignment {
    LeftAligned,  // Standard left-aligned layout
    Centered      // Centered text and avatar header
}

enum class Ux4gModalLeadingItem {
    None,    // No leading element
    Icon,    // Small inline icon beside title
    Avatar,  // Circular citizen avatar
    Image    // Small thumbnail image
}

enum class Ux4gModalHeaderImage {
    FullBleed,  // Top image spanning full width
    Padded,     // Padded image card with rounded corners
    None        // No top hero image
}

enum class Ux4gModalFooterButtons {
    OneButton,            // Single primary button
    TwoButtons,           // Secondary outline + Primary filled
    OneButtonWithIcon,    // Leading helper icon + Primary button
    TwoButtonsWithIcon    // Leading helper icon + Secondary + Primary
}

enum class Ux4gModalFooterAlign {
    Left,    // Buttons aligned to left
    Right,   // Buttons aligned to right
    Center,  // Buttons centered
    Split    // Secondary left, Primary right
}

On this page