X Enterprises
nuxt-x-app

Modal

Flexible modal dialogs including a general-purpose modal, a confirmation dialog, and a key-value data viewer.

Modal

The Modal category provides three composable dialog components built on top of Nuxt UI's UModal. XAModal is the general container; XAModalConfirm handles destructive action confirmations; XAModalKeyValue presents structured data in a readable format. All three support both v-model and internal open-state management, and expose open() / close() methods via defineExpose.

Components

<XAModal />

A flexible modal with a header (title + close button), a scrollable body, and an optional footer. An inline trigger button is rendered when triggerLabel or triggerIcon props are provided. The #trigger slot can replace the default button entirely.

<XAModal
  v-model="showModal"
  title="Edit Profile"
  size="lg"
  :closable="true"
>
  <p>Modal body content goes here.</p>

  <template #footer>
    <div class="flex justify-end gap-3">
      <UButton variant="ghost" @click="showModal = false">Cancel</UButton>
      <UButton @click="save">Save</UButton>
    </div>
  </template>
</XAModal>

<!-- Self-contained with trigger button -->
<XAModal title="Create Item" trigger-label="New Item" trigger-icon="i-lucide-plus">
  <CreateItemForm />
</XAModal>

Props

PropTypeDefaultDescription
modelValueBooleanundefinedv-model open state
titleString''Modal header title
sizeString'md'Modal width: xs sm md lg xl 2xl 3xl 4xl 5xl full
closableBooleantrueShow the close (×) button in the header
triggerLabelString''Text for the built-in trigger button
triggerIconString''Icon for the built-in trigger button
triggerColorString'primary'Color of the trigger button
triggerVariantString'solid'Variant of the trigger button
triggerSizeString'md'Size of the trigger button

Slots

SlotDescription
triggerReplace the default trigger button
headerReplace the default header content
defaultModal body content
footerModal footer content

<XAModalConfirm />

A focused confirmation dialog. The icon and button color adapt to the variant prop (danger, warning, info). Supports loading state during async confirm actions.

<XAModalConfirm
  v-model:open="showConfirm"
  title="Delete User"
  message="This action cannot be undone. The user and all associated data will be permanently deleted."
  variant="danger"
  confirm-text="Delete"
  :loading="deleting"
  @confirm="deleteUser"
  @cancel="showConfirm = false"
/>

Props

PropTypeDefaultDescription
modelValueBooleanundefinedv-model open state
openBooleanundefinedv-model:open alternative
titleString'Confirm'Dialog title
messageString''Body message text
variantString'info'Visual style: danger warning info
colorString''Alternative to variant using color names
confirmTextString'Confirm'Confirm button label
cancelTextString'Cancel'Cancel button label
iconString''Override the auto-selected variant icon
loadingBooleanfalseShow loading state on the confirm button

Events

EventPayloadDescription
confirmEmitted when the confirm button is clicked
cancelEmitted when the cancel button is clicked

<XAModalKeyValue />

Displays a structured object or array of fields in a modal using XAFmtData. Useful for record detail views, audit logs, or quick-look inspections.

<XAModalKeyValue
  v-model="showDetails"
  title="Order Details"
  :data="{
    orderId: 'ORD-1234',
    status: 'Shipped',
    total: '$149.00',
    createdAt: '2025-03-01'
  }"
  size="lg"
  layout="horizontal"
/>

<!-- With array-form data for full control -->
<XAModalKeyValue
  title="User Details"
  trigger-label="View"
  :data="[
    { key: 'name', label: 'Full Name', value: user.name },
    { key: 'role', label: 'Role', value: user.role, type: 'badge' }
  ]"
/>

Props

PropTypeDefaultDescription
modelValueBooleanundefinedv-model open state
titleString''Modal title
dataObject | Array{}Data to display — plain object or array of field descriptors
sizeString'md'Modal width: sm md lg xl
layoutString'horizontal'Layout passed to XAFmtData
spacingString'md'Spacing passed to XAFmtData
triggerLabelString''Text for the built-in trigger button
triggerIconString''Icon for the built-in trigger button
triggerColorString'primary'Color of the trigger button
triggerVariantString'solid'Variant of the trigger button
triggerSizeString'md'Size of the trigger button

Slots

SlotDescription
triggerReplace the default trigger button
footerOptional footer content below the data

AI Context

category: Modal
package: "@xenterprises/nuxt-x-app"
use-when: >
  Use XAModal for any arbitrary dialog content. Use XAModalConfirm for
  destructive or irreversible actions (delete, revoke, deactivate) where
  user intent must be confirmed. Use XAModalKeyValue to surface read-only
  structured data (record details, audit entries) in a quick-look overlay
  without building a custom layout.
Copyright © 2026