Bridge UI

useDialogAction

Imperative confirm-style dialogs with title, description, and footer actions.

Introduction

useDialogAction opens preset confirm-style dialogs without declaring <Modal> in your template. Each entry renders a Modal shell with a Card header, body, and footer actions.

Mount BridgeUIHosts (with BridgeDialogHost) near the root of your app—typically inside BridgeUIProvider. The hook returns open, close, closeTop, update, isOpen, and stackSize.

Use the framework selector in the site header to switch between React and Vue.

Import

import { BridgeUIHosts } from "@bridge-ui/vue/Actions";
import { useDialogAction } from "@bridge-ui/vue/Actions";
import { BridgeUIHosts } from "@bridge-ui/react/Actions";
import { useDialogAction } from "@bridge-ui/react/Actions";

Setup

Caution

Mount BridgeUIHosts with the dialog host inside BridgeUIProvider or open() will do nothing.

Wrap your app (or layout) with BridgeUIProvider and BridgeUIHosts:

<script setup lang="ts">
import { BridgeUIProvider } from "@bridge-ui/vue";
import { BridgeUIHosts } from "@bridge-ui/vue/Actions";
</script>

<template>
  <BridgeUIProvider :global="{}" :components="{}">
    <BridgeUIHosts :dialog="{ modal: { transition: 'fade' } }">
      <!-- routes / pages -->
    </BridgeUIHosts>
  </BridgeUIProvider>
</template>
import { BridgeUIProvider } from "@bridge-ui/react";
import { BridgeUIHosts } from "@bridge-ui/react/Actions";

export function App() {
  return (
    <BridgeUIProvider global={{}} components={{}}>
      <BridgeUIHosts dialog={{ modal: { transition: "fade" } }}>
        {/* routes / pages */}
      </BridgeUIHosts>
    </BridgeUIProvider>
  );
}

Basic usage

Call open() with title, description, and actions for the footer buttons. open() returns an entry id you pass to close(id).

Pass modal on open() to control shell options such as size, transition, and align. Use color for semantic tinting on the Card content.

Destructive dialogs

Combine color: "error" with reject/accept actions for delete or irreversible confirmations.

close / closeTop / stack

Multiple dialogs can be open at once. Use close(id) for a specific entry, closeTop() for the topmost layer, and stackSize / isOpen(id) to inspect state.

Callbacks

onClose runs when a dismiss starts (overlay, Escape, footer actions, or close ). onClosed runs after the leave animation.

update

Patch an open entry with update(id, { props, modal }) to change content or shell options without closing and reopening.

persistent

Set modal.persistent: true to ignore Escape and overlay clicks. The user must use a footer action to dismiss.

Nested stack

Open a second dialog from a footer action while the first stays mounted—useful for multi-step confirmations.

API

Method / property Description
open(options) Opens a dialog. Returns an entry id.
close(id) Closes the entry with the given id.
closeTop() Closes the topmost entry in the stack.
update(id, patch) Patches props and/or modal shell options on an open entry.
isOpen(id) Whether the entry is currently open.
stackSize Number of open dialog entries.

open options

Option Type Description
title string Dialog headline.
description string Body text below the title.
color AlertColor Semantic color for the dialog.
actions { accept?, reject? } Footer buttons with label and optional onClick.
modal ModalOptions Shell options: size, transition, persistent, etc.
onClose () => void Called when a dismiss starts.
onClosed () => void Called after the leave animation.

Modal, Card, useModalAction