BoxDialog.vue component is a reusable Vue.js component for creating modal dialog boxes. It integrates with the useBoxStore Pinia store to manage its open and close states programmatically. This component is typically used for displaying forms, confirmations, or any other contextual content requiring user interaction.
Features
Open/Close Management
Uses
useBoxStore to control the open/close state of the dialog.Customizable Content
Supports custom header, body, and footer content via slots.
Closable
Includes an optional close button for user convenience.
Programmatic Control
Allows programmatic open/close functionality using the
useBoxStore.Usage
Basic Example
Props
The unique identifier for the dialog box, used to control its state via
useBoxStore.Determines whether the dialog includes a close button.
The HTML tag to wrap the inside of the box with.
Slots
Slot for the dialog header content, typically a title or icon.
<template #header></template>The main content area of the dialog.
Slot for the dialog footer content, typically buttons.
<template #footer></template>Example Use Cases
Simple Dialog with Header and Footer
Programmatically Opening a Dialog
Form Submission
Dialog boxes are automatically wrapped in a form tag.Notes
- State Management: The
useBoxStorePinia store is required to manage the open/close state of theBoxDialogcomponent. Ensure the store is properly imported and configured. - Custom Content: Use the
header,footer, and default slots to customize the dialog content as needed. - Closable Option: Use the
closableprop to toggle the presence of the close button. Iffalse, the dialog can only be closed programmatically or by interacting with external buttons. - Responsive Design: The dialog box can be styled using the
classattribute to adjust its size or layout.