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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mrshanebarron/modal 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Fork from ghosh/Micromodal. Tiny, dependency-free javascript library for creating accessible modal dialogs.
Make Filament modals draggable.
A Filament form component that displays repeater items in a table with modal-based editing.
Send events to a websocket real time engine though PHP
A Laravel Nova field. To create a modal for creating or viewing related HasMany records without leaving the index page
Custom fields for Kirby's add dialog. This plugin allows to define the fields shown on the page add dialog in a page's blueprint.
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-16