mrshanebarron/modal 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrshanebarron/modal

Composer 安装命令:

composer require mrshanebarron/modal

包简介

Modal dialog component for Laravel - supports Livewire and Vue

README 文档

README

A flexible, accessible modal dialog component for Laravel applications. Features smooth animations, multiple sizes, and customizable behavior. Works with Livewire and Vue 3.

Installation

composer require mrshanebarron/modal

Livewire Usage

Basic Usage

<button wire:click="$set('showModal', true)">Open Modal</button>

<livewire:sb-modal wire:model="showModal" title="My Modal">
    <p>Modal content goes here.</p>
</livewire:sb-modal>

With Footer Actions

<livewire:sb-modal wire:model="showModal" title="Confirm Action">
    <p>Are you sure you want to proceed?</p>

    <x-slot name="footer">
        <button wire:click="$set('showModal', false)">Cancel</button>
        <button wire:click="confirm">Confirm</button>
    </x-slot>
</livewire:sb-modal>

Different Sizes

<livewire:sb-modal wire:model="showSmall" size="sm" title="Small Modal">
    Small modal content.
</livewire:sb-modal>

<livewire:sb-modal wire:model="showLarge" size="xl" title="Large Modal">
    Large modal content.
</livewire:sb-modal>

Livewire Props

Prop Type Default Description
wire:model boolean required Controls modal visibility
title string null Modal header title
size string 'md' Size: sm, md, lg, xl, 2xl, full
close-on-escape boolean true Close when Escape pressed
close-on-overlay boolean true Close when clicking overlay

Vue 3 Usage

Setup

import { SbModal } from './vendor/sb-modal';
app.component('SbModal', SbModal);

Basic Usage

<template>
  <button @click="showModal = true">Open Modal</button>

  <SbModal v-model="showModal" title="My Modal">
    <p>Modal content goes here.</p>
  </SbModal>
</template>

<script setup>
import { ref } from 'vue';
const showModal = ref(false);
</script>

With Header and Footer Slots

<template>
  <SbModal v-model="showModal">
    <template #header>
      <div class="flex items-center gap-2">
        <span class="text-red-500">Warning</span>
        Custom Header
      </div>
    </template>

    <p>Are you sure you want to delete this item?</p>

    <template #footer>
      <SbButton variant="secondary" @click="showModal = false">
        Cancel
      </SbButton>
      <SbButton variant="danger" @click="deleteItem">
        Delete
      </SbButton>
    </template>
  </SbModal>
</template>

Sizes

<template>
  <SbModal v-model="show" size="sm" title="Small">...</SbModal>
  <SbModal v-model="show" size="md" title="Medium">...</SbModal>
  <SbModal v-model="show" size="lg" title="Large">...</SbModal>
  <SbModal v-model="show" size="xl" title="Extra Large">...</SbModal>
  <SbModal v-model="show" size="2xl" title="2XL">...</SbModal>
  <SbModal v-model="show" size="full" title="Full Width">...</SbModal>
</template>

Prevent Closing

<template>
  <!-- Don't close on escape or overlay click -->
  <SbModal
    v-model="showModal"
    title="Important Form"
    :close-on-escape="false"
    :close-on-overlay="false"
  >
    <p>Fill out this form before closing.</p>
  </SbModal>
</template>

Vue Props

Prop Type Default Description
modelValue Boolean false Controls visibility (v-model)
title String null Header title text
size String 'md' Modal width: sm, md, lg, xl, 2xl, full
closeOnEscape Boolean true Close on Escape key
closeOnOverlay Boolean true Close on backdrop click

Events

Event Description
update:modelValue Emitted when visibility changes
close Emitted when modal closes

Slots

Slot Description
default Modal body content
header Custom header content
footer Footer content (buttons, etc.)

Features

  • Teleport: Modal renders at document body level
  • Body Scroll Lock: Prevents background scrolling when open
  • Focus Management: Focuses modal on open
  • Animations: Smooth fade transitions
  • Accessibility: Proper ARIA attributes and keyboard handling

Styling

Default styling uses Tailwind CSS:

  • White background with rounded corners
  • Gray border separators for header/footer
  • Semi-transparent black overlay
  • Centered positioning with padding

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12
  • Tailwind CSS 3.x

License

MIT License

mrshanebarron/modal 适用场景与选型建议

mrshanebarron/modal 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「dialog」 「modal」 「popup」 「vue」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mrshanebarron/modal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mrshanebarron/modal 我们能提供哪些服务?
定制开发 / 二次开发

基于 mrshanebarron/modal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-16