Skip to content

App

Host programmatic modals without changing the visual structure of your application.

A host at the root

UIApp renders the content of its snippet and the modal stack of the manager. It does not create an extra visual container. Use it once around the outlet.

app/app.meeko meeko
<!-- app/app.meeko -->
<template>
  <UIApp>
    <MeekoOutlet />
  </UIApp>
</template>

Contract

It has no public props or events. It requires the default snippet. The plugin registered by @meekojs/ui provides the context; you do not need to create your own plugin or call provideModal.

useModal() opens components whose name starts with Modal, with the props of your application's component registry. useModalInstance() closes the current instance with a result or dismisses it.

Inside a component ts
const modal = useModal()

// Call this function from a user action.
async function confirm() {
  const accepted = await modal.open<boolean>('ModalConfirm', {
    message: 'Do you want to confirm this action?',
  })
  // boolean | undefined: dismissing returns undefined.
  return accepted
}

See the Modal guide for the confirmation component, the sizes and the protected closes.

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters