mrshanebarron/dropdown
Composer 安装命令:
composer require mrshanebarron/dropdown
包简介
Dropdown menu component for Laravel - supports Livewire and Vue
README 文档
README
A dropdown menu component for Laravel applications. Supports various widths, alignments, and auto-close behaviors. Works with Livewire and Vue 3.
Installation
composer require mrshanebarron/dropdown
Livewire Usage
Basic Usage
<livewire:sb-dropdown> <x-slot name="trigger"> <button>Options</button> </x-slot> <a href="#" class="block px-4 py-2 hover:bg-gray-100">Edit</a> <a href="#" class="block px-4 py-2 hover:bg-gray-100">Delete</a> </livewire:sb-dropdown>
Right Aligned
<livewire:sb-dropdown align="right"> <x-slot name="trigger"> <button>Menu</button> </x-slot> <a href="#">Profile</a> <a href="#">Settings</a> <a href="#">Logout</a> </livewire:sb-dropdown>
Custom Width
<livewire:sb-dropdown width="72"> <x-slot name="trigger"> <button>Wide Menu</button> </x-slot> <div class="p-4">Custom content here</div> </livewire:sb-dropdown>
Livewire Props
| Prop | Type | Default | Description |
|---|---|---|---|
align |
string | 'left' |
Alignment: left, right, center |
width |
string | '48' |
Width: 48, 56, 64, 72, 96 |
close-on-click |
boolean | true |
Close when item clicked |
close-on-outside-click |
boolean | true |
Close on outside click |
Vue 3 Usage
Setup
import { SbDropdown, SbDropdownItem } from './vendor/sb-dropdown'; app.component('SbDropdown', SbDropdown); app.component('SbDropdownItem', SbDropdownItem);
Basic Usage
<template> <SbDropdown> <template #trigger> <button class="px-4 py-2 bg-gray-100 rounded"> Options </button> </template> <a href="#" class="block px-4 py-2 hover:bg-gray-100">Edit</a> <a href="#" class="block px-4 py-2 hover:bg-gray-100">Duplicate</a> <a href="#" class="block px-4 py-2 hover:bg-gray-100">Delete</a> </SbDropdown> </template>
Alignment Options
<template> <!-- Left aligned (default) --> <SbDropdown align="left">...</SbDropdown> <!-- Right aligned --> <SbDropdown align="right">...</SbDropdown> <!-- Center aligned --> <SbDropdown align="center">...</SbDropdown> </template>
Width Options
<template> <SbDropdown width="48">...</SbDropdown> <!-- 12rem --> <SbDropdown width="56">...</SbDropdown> <!-- 14rem --> <SbDropdown width="64">...</SbDropdown> <!-- 16rem --> <SbDropdown width="72">...</SbDropdown> <!-- 18rem --> <SbDropdown width="96">...</SbDropdown> <!-- 24rem --> </template>
User Menu Example
<template> <SbDropdown align="right" width="56"> <template #trigger> <button class="flex items-center gap-2"> <SbAvatar :src="user.avatar" :name="user.name" size="sm" /> <span>{{ user.name }}</span> </button> </template> <div class="px-4 py-3 border-b"> <p class="text-sm text-gray-900">{{ user.name }}</p> <p class="text-xs text-gray-500">{{ user.email }}</p> </div> <a href="/profile" class="block px-4 py-2 hover:bg-gray-100">Profile</a> <a href="/settings" class="block px-4 py-2 hover:bg-gray-100">Settings</a> <div class="border-t"> <button @click="logout" class="block w-full px-4 py-2 text-left text-red-600 hover:bg-gray-100"> Logout </button> </div> </SbDropdown> </template>
Prevent Auto-Close
<template> <!-- Don't close when clicking items --> <SbDropdown :close-on-click="false"> <template #trigger> <button>Filters</button> </template> <label class="flex items-center px-4 py-2"> <input type="checkbox" v-model="filters.active" class="mr-2"> Active </label> <label class="flex items-center px-4 py-2"> <input type="checkbox" v-model="filters.archived" class="mr-2"> Archived </label> </SbDropdown> </template>
Vue Props
| Prop | Type | Default | Description |
|---|---|---|---|
align |
String | 'left' |
Position: left, right, center |
width |
String | '48' |
Width class suffix |
closeOnClick |
Boolean | true |
Close when content clicked |
closeOnOutsideClick |
Boolean | true |
Close on outside click |
Slots
| Slot | Description |
|---|---|
trigger |
Element that opens dropdown |
| default | Dropdown menu content |
Features
- Auto-close: Closes on outside click and Escape key
- Animations: Smooth fade and slide transitions
- Flexible Width: Multiple preset width options
- Alignment: Left, right, or center aligned
Accessibility
role="menu"attributearia-orientation="vertical"- Escape key closes menu
- Focus management
Styling
Uses Tailwind CSS:
- White background with shadow
- Ring border effect
- Smooth transition animation
- Z-index for proper stacking
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Tailwind CSS 3.x
License
MIT License
mrshanebarron/dropdown 适用场景与选型建议
mrshanebarron/dropdown 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「menu」 「laravel」 「dropdown」 「popover」 「vue」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mrshanebarron/dropdown 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrshanebarron/dropdown 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mrshanebarron/dropdown 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bootstrap dropdown list with AJAX data.
A Symfony extension to get active class base on current bundle/controller/action
A simple state dropdown field for SilverStripe forms
Use JSON templates as field options for dropdown, radio or checkboxes.
A Laravel Nova Multiselect Dropdown Field.
AssetBundle for https://cameronspear.com/demos/bootstrap-hover-dropdown/
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-16