Skip to content

ConfirmModal

Confirm Modal use to preventing accidental actions. When the user needs to perform a potentially dangerous action, a Modal can be used to display a confirmation dialog to prevent accidental actions that could have negative consequences.

Basic Usage

View Source
vue
<script setup lang="ts">
import { useUniConfirmModal, UniButton } from "unify-ui";

const { confirm } = useUniConfirmModal();

async function handleConfirmDialogButton() {
  try {
    await confirm({
      title: "Tips",
      supportingText: "Are you sure you want to delete this record?",
    });
    console.log("confirm");
  } catch (error) {
    console.log(error);
  }
}
</script>

<template>
  <UniButton type="soft" @click="handleConfirmDialogButton"> Show Confirm Dialog </UniButton>
</template>

APIS

confirm

ts
interface ConfirmOptions {
  title: string;
  supportingText: string;
}

function confirm(options: ConfirmOptions): Promise<"confirm" | "cancel">;

Released under the MIT License.