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

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

Kotlin Usage
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
| Prop | Type | Description | Default |
|---|---|---|---|
onDismiss * | () -> Unit | Callback invoked when citizen dismisses dialog by clicking backdrop, back press, or close icon. | — |
modifier | Modifier | Compose layout modifier. | Modifier |
headerImageUrl | String? | 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 |
headerImageHeight | Dp | Height of the top hero image area. | 160.dp |
headerImageStyle | Ux4gModalHeaderImage | Hero image style: FullBleed, Padded, or None. | Ux4gModalHeaderImage.FullBleed |
leadingItem | Ux4gModalLeadingItem | Header leading element: None, Icon, Avatar, or Image. | Ux4gModalLeadingItem.None |
leadingIcon | Ux4gIcon | Icon rendered when leadingItem = Ux4gModalLeadingItem.Icon. | Ux4gIcons.info_circle |
leadingIconTint | Color? | Custom color tint for the leading icon. | null |
avatarInitials | String? | Initials string rendered when leadingItem = Ux4gModalLeadingItem.Avatar. | null |
avatarImageUrl | Any? | Image URL or resource for avatar. | null |
avatarIcon | Ux4gIcon? | Fallback icon for avatar. | null |
showHeader | Boolean | Controls visibility of the header section. | true |
headerTitle | String | Main title text displayed in the header. | "Header" |
showDescription | Boolean | Controls visibility of the description text below header title. | false |
descriptionText | String | Description text content below header title. | "Write description here" |
showDividers | Boolean | Renders divider lines separating header, body, and footer. | true |
showSubtitle | Boolean | Controls visibility of the subtitle heading inside body. | true |
subtitleText | String | Subtitle text content. | "Subtitle" |
showBody | Boolean | Controls visibility of the main body content. | true |
bodyText | String | Paragraph text in the body area. | "A modal is a design element..." |
bodyContent | (@Composable () -> Unit)? | Custom composable slot replacing standard bodyText. | null |
showFooter | Boolean | Controls visibility of the footer actions section. | true |
footerButtons | Ux4gModalFooterButtons | Button layout: OneButton, TwoButtons, OneButtonWithIcon, or TwoButtonsWithIcon. | Ux4gModalFooterButtons.TwoButtons |
footerAlign | Ux4gModalFooterAlign | Alignment of buttons: Left, Right, Center, or Split. | Ux4gModalFooterAlign.Right |
isDestructive | Boolean | When true, renders primary button in destructive error red tone. | false |
primaryButtonText | String | Label for the primary filled action button. | "Button" |
secondaryButtonText | String | Label for the secondary outline button. | "Button" |
leadingActionIcon | Ux4gIcon | Icon 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 |
alignment | Ux4gModalAlignment | Content alignment: LeftAligned or Centered. | Ux4gModalAlignment.LeftAligned |
showCloseButton | Boolean | Whether to display the top-right close icon button. | true |
backgroundColor | Color? | Modal card background color. | Ux4gColors.white |
cornerRadius | Dp | Corner 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
}