emuniq/filament-scrollable-topnav 问题修复 & 功能扩展

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

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

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

Latest Version on Packagist Total Downloads License

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

Topnav scrolling with mouse wheel and edge fade

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

  1. Critical inline CSS via the HEAD_END render hook applies flex-wrap: nowrap and white-space: nowrap immediately on parse, preventing FOUC.
  2. Filament asset CSS (plugin.css) provides the full styling: hidden scrollbar, mask-image edge fades, scroll-snap rules — all gated by data-* attributes that the JS toggles.
  3. Filament asset JS (plugin.js) listens for wheel, scroll, focusin, and resize events on .fi-topbar-nav-groups. It detects mouse wheels (which only emit deltaY) and converts them to horizontal scroll while preserving native trackpad horizontal swipes (deltaX). It also normalizes WheelEvent.deltaMode so high-resolution and line-step wheels both feel right.
  4. Config injection — the inline <script> sets window.scrollableTopnavConfig before the deferred plugin JS runs, so each panel can have its own settings.

Compatibility Notes

  • The 1024px breakpoint matches Filament's lg, where topNavigation() becomes a row instead of a sidebar. Below it the plugin is a no-op.
  • mask-image is 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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-30