Skip to content

PromptDialog

@Composable



fun ModalScope.PromptDialog(
    title: Component, 
    initialValue: String = "", 
    prompt: Component = Component.literal("Enter a value:"), 
    confirmText: Component = Component.literal("Confirm"), 
    cancelText: Component = Component.literal("Cancel"), 
    validator: (String) -> Boolean = { true }, 
    onConfirm: (String) -> Unit, 
    onCancel: () -> Unit = {}
)

Input modal with an inline text field and explicit confirm/cancel actions.

Parameters

  • title: The dialog's header text.

  • initialValue: The text field's starting value.

  • prompt: Label text shown above the text field.

  • confirmText: Label for the confirm button.

  • cancelText: Label for the cancel button.

  • validator: The confirm button is only enabled while this returns true for the current field value.

  • onConfirm: Called with the field's value just before the modal dismisses itself.

  • onCancel: Called just before the modal dismisses itself via the cancel button.