Filament sorts navigation groups alphabetically by default. If you want to control the order of navigation groups in the sidebar menu, you can use the navigationGroup() method along with the navigationSort() method on your resource or page classes.
Here's how you can do it:
public static function navigationGroup(): ?string
{
return 'Your Group Name';
}
public static function navigationSort(): ?int
{
return 1; // Lower numbers appear first
}
Assign a different navigationSort value to each resource or page within a group to control their order. However, to control the order of the groups themselves, you should prefix the group names with numbers or letters, like so:
public static function navigationGroup(): ?string
{
return '1. Users';
}
public static function navigationGroup(): ?string
{
return '2. Products';
}
This way, Filament will sort the groups according to your prefix, giving you full control over the order.
Summary:
- Use
navigationSort()to order resources/pages within a group. - Prefix group names (e.g.,
'1. Users','2. Products') to control the order of navigation groups.
Let me know if you need a more detailed example!