Skip to content

Alert ​

Centered confirmation dialog for a single decision, mapped to Material 3 AlertDialog: title, optional message, and cancel + confirm actions. The confirm action turns danger-colored when destructive; stacked lays the two actions vertically instead of side by side.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismAlert

Basic usage ​

kotlin
var open by remember { mutableStateOf(false) }

PrismButton(onClick = { open = true }) { Text("Delete") }

PrismAlert(
    open = open,
    onClose = { open = false },
    title = "Delete?",
    message = "This cannot be undone.",
    destructive = true,
    onConfirm = { open = false },
)

Stacked actions ​

stacked lays cancel above confirm in a vertical column.

kotlin
PrismAlert(
    open = open,
    onClose = { open = false },
    title = "Sign out?",
    confirmLabel = "Sign out",
    cancelLabel = "Stay",
    stacked = true,
    onConfirm = { open = false },
)

API ​

ParameterTypeDefaultDescription
openBoolean—Whether the alert is visible; renders nothing when false.
onClose() -> Unit—Fires on cancel, scrim dismiss, or Escape.
titleString—Headline of the decision.
modifierModifierModifierModifier applied to the dialog.
messageString?nullOptional supporting text under the title.
confirmLabelString"确认"Confirm button label.
cancelLabelString"取消"Cancel button label.
destructiveBooleanfalseColor the confirm action as destructive (danger).
stackedBooleanfalseStack the buttons vertically (cancel above confirm).
onConfirm() -> Unit{}Fires when the confirm button is pressed.

Released under the MIT License.