概述
简介
默认情况下,Filament 将为每个资源、自定义页面 和 Clusters 注册导航项目。这些类都包含一些静态属性和方法,你可以重写配置导航项目。
如果你想在应道的导航中添加第二层导航,可以使用 Clusters。这对于将资源和页面分组到一起很有用。
自定义导航项标签
默认情况下,导航标签是由资源或者页面名称生成。你可以使用 $navigationLabel 属性自定义:
protected static ?string $navigationLabel = 'Custom Navigation Label';
此外,你也可以自定义 getNavigationLabel() 方法:
public static function getNavigationLabel(): string
{
return 'Custom Navigation Label';
}
自定义导航项图标
要自定义导航项的图标,你可以重写资源或页面类的 $navigationIcon 属性:
use BackedEnum;
protected static string | BackedEnum | null $navigationIcon = 'heroicon-o-document-text';
如果你将同一导航分组内的所有项目都设置 $navigationIcon = null,则这些项目将通过分组标签下方的垂直条连接起来。
当导航项激活时切换图标
通过 $activeNavigationIcon 属性,你指定一个仅用于导航项激活时的图标:
protected static ?string $activeNavigationIcon = 'heroicon-o-document-text';
导航项排序
默认情况下,导航项按照字母顺序排序。你可以使用 $navigationSort 属性自定义排序:
protected static ?int $navigationSort = 3;
排序值较低的导航项会排在排序值高的项目之前,排序顺序为升序。

