Skip to content

modal service

The programmatic entry point for opening dialogs from code, without declaring anything in a template. Requires a single <modal-view /> mounted in your app root.

typescript
import { modal } from '@dynamicforms/vuetify-modal-form-kit';

const result = await modal.message('Done', 'Your changes have been saved.');

Every method returns a CloseablePromise<string> - a Promise that resolves to the name of the action that closed the dialog (e.g. 'close', 'yes', 'no', or a custom action's name), plus:

MemberDescription
.close(value)Closes the dialog from outside, resolving the promise with value.
.dialogIdsymbol identifying this dialog in the internal stack.

Methods

MethodSignatureDescription
messagemessage(title, message, options?)Shows a message dialog. Gets a single close action unless options.form or options.actions define their own.
yesNoyesNo(title, message, options?)Shows a confirmation dialog with yes / no actions unless options.form or options.actions define their own.
customcustom(title, componentName, componentProps, options?)Shorthand for message() that renders a registered component (componentName) with componentProps as the body.

title and message accept a plain string, MdString (Markdown), a SimpleComponentDef, or a RenderableValue wrapping any of those (e.g. to attach an extra CSS class).

ModalOptions

Passed as the last argument to message() / yesNo() / custom().

OptionTypeDescription
formForm.GroupA @dynamicforms/vue-forms group rendered as the dialog body. Any Action fields on it are used as the dialog's actions.
actionsRecord<string, Action>Explicit actions to show, keyed by name. Merged over the defaults (close, or yes / no).
sizeDialogSizeOne of DialogSize.SMALL / MEDIUM / LARGE / X_LARGE. Defaults to DialogSize.DEFAULT.
colorstringPassed straight to the title bar's v-sheet color prop.
iconstringIcon shown next to the title.

DialogSize

import { DialogSize } from '@dynamicforms/vuetify-modal-form-kit'

Enum with SMALL, MEDIUM, LARGE, X_LARGE and DEFAULT members, accepted by both ModalOptions.size and df-modal's size prop. On small screens the dialog automatically switches to fullscreen regardless of the configured size.

typescript
import { modal, DialogSize } from '@dynamicforms/vuetify-modal-form-kit';

await modal.message('Information', 'This is a large dialog', { size: DialogSize.LARGE });

Examples

See Modal Dialog for worked examples of message dialogs, confirmations, Markdown content, form dialogs, custom components, and sizing.

Released under the MIT License.