emuniq/filament-scrollable-topnav
Composer 安装命令:
composer require emuniq/filament-scrollable-topnav
包简介
Makes Filament's top navigation scrollable instead of wrapping into multiple rows when you have many navigation groups/clusters.
README 文档
README
A Filament v3 & v4 plugin that turns the top navigation into a single scrollable row instead of letting it wrap into multiple rows when you have many navigation groups or clusters. Adds horizontal mouse-wheel scrolling and an edge-fade affordance so users can tell there's more to see.
Demo
The Problem
Filament's topNavigation() wraps clusters into two (or more) rows when they don't fit, eating vertical space and looking cluttered. Two-word labels can also break across lines. With a lot of clusters there's no visual hint that more navigation exists off-screen, and a regular mouse wheel can't scroll it.
The Solution
- Forces the topnav into a single row with a hidden scrollbar.
- Mouse-wheel scrolling: vertical wheel ticks scroll the topnav horizontally.
- Edge fade affordance: a soft gradient appears on the leading/trailing edges only when there's more content in that direction, so users instinctively scroll.
- Optional scroll-snap so swipes/wheel land on cluster boundaries.
- Auto-scrolls focused items into view for keyboard navigation.
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Filament 3.0+ or 4.0+
Installation
composer require emuniq/filament-scrollable-topnav
Register the plugin in your panel provider:
use Emuniq\FilamentScrollableTopnav\ScrollableTopnavPlugin; public function panel(Panel $panel): Panel { return $panel ->topNavigation() ->plugins([ ScrollableTopnavPlugin::make(), ]); }
That's it. The plugin ships its own CSS and JS as Filament assets and injects a small inline <style> + config block via the HEAD_END render hook to prevent the brief double-row flash before the asset CSS loads.
Optional: bundle into a custom theme
If you have a custom Filament theme and want the styles compiled into your theme bundle (zero FOUC, fully cacheable), import the plugin CSS:
php artisan scrollable-topnav:install npm run build
Or manually add to resources/css/filament/{panel}/theme.css:
@import '../../../../vendor/emuniq/filament-scrollable-topnav/resources/css/plugin.css';
Configuration
Every behavior is opt-in/out via builder methods on ScrollableTopnavPlugin::make():
| Method | Default | What it does |
|---|---|---|
->fadeSize(string $size) |
'36px' |
Width of the edge fade gradient. Any CSS length. |
->edgeHints(bool) |
true |
Show the fade gradient when there's overflow in that direction. |
->wheelToScroll(bool) |
true |
Translate vertical mouse-wheel deltas into horizontal scroll on the topnav. |
->autoScrollToFocus(bool) |
true |
Scroll a focused (:focus) cluster into view — keyboard accessibility. |
->scrollSnap(bool) |
false |
Snap scroll position to cluster boundaries (scroll-snap-type: x proximity). |
Example with everything tuned:
ScrollableTopnavPlugin::make() ->fadeSize('48px') ->scrollSnap() ->wheelToScroll(false), // disable on a panel that already uses wheel for something else
How It Works
- Critical inline CSS via the
HEAD_ENDrender hook appliesflex-wrap: nowrapandwhite-space: nowrapimmediately on parse, preventing FOUC. - Filament asset CSS (
plugin.css) provides the full styling: hidden scrollbar, mask-image edge fades, scroll-snap rules — all gated bydata-*attributes that the JS toggles. - Filament asset JS (
plugin.js) listens forwheel,scroll,focusin, andresizeevents on.fi-topbar-nav-groups. It detects mouse wheels (which only emitdeltaY) and converts them to horizontal scroll while preserving native trackpad horizontal swipes (deltaX). It also normalizesWheelEvent.deltaModeso high-resolution and line-step wheels both feel right. - Config injection — the inline
<script>setswindow.scrollableTopnavConfigbefore the deferred plugin JS runs, so each panel can have its own settings.
Compatibility Notes
- The 1024px breakpoint matches Filament's
lg, wheretopNavigation()becomes a row instead of a sidebar. Below it the plugin is a no-op. mask-imageis supported in all evergreen browsers. IE11 isn't supported (Filament 4 doesn't support it either).- Livewire navigation is handled — the plugin re-binds on
livewire:navigated.
License
MIT
emuniq/filament-scrollable-topnav 适用场景与选型建议
emuniq/filament-scrollable-topnav 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「navigation」 「laravel」 「scrollable」 「filament」 「topbar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 emuniq/filament-scrollable-topnav 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 emuniq/filament-scrollable-topnav 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 emuniq/filament-scrollable-topnav 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shim repository for https://github.com/rochal/jQuery-slimScroll
A block to display a list of links to child pages, or pages in current level
Laravel Menu management
Alfabank REST API integration
Create simple top navigation for laravel
GUI for monitoring usage in real-time for appui
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-30
