---
url: /filament-relation-navigator/guide/menu-presets.md
---
# Menu presets and options

Publish the config:

```bash
php artisan vendor:publish --tag=filament-relation-navigator-config
```

```php
'menu' => [
    'preset' => 'github',   // 'simple', a preset of yours, or a view name
    'presets' => [
        'simple' => 'filament-relation-navigator::menu.simple',
        'github' => 'filament-relation-navigator::menu.github',
    ],
    'searchable' => true,   // a search field on top of the list, whatever the preset
    'search_from' => 0,     // ...from this many items
    'badges' => 'lazy',     // the relation managers' badges: 'lazy' when the menu opens, true with the page, false off
    'max_height' => '24rem',
    'separator' => true,    // record pages and relation pages in two blocks
    'mobile' => true,       // the menu above the heading on small screens
    'shortcut' => 'alt+shift+r', // opens the menu; null turns it off
],
```

**github** (the default): the last breadcrumb stays text and a caret next to
it opens a panel with a heading, a search field and a check on the current
page, like GitHub's repository switcher. The field gets the focus when the
menu opens and Enter opens the first match.

**simple**: the last breadcrumb itself opens the list. For the menu of 1.2
and earlier, set `'preset' => 'simple'` and `'searchable' => false`.

### Badges

The menu shows the relation managers' badges, as in their tabs. By default
they are **loaded when the menu opens**: the menu is closed until then, so the
page renders without their queries, also on every Livewire request that
redraws the breadcrumbs. A spinner shows for the moment they take.

```php
'badges' => 'lazy', // default; true: with the page; false: no badges
```

Turn them off where you need to:

```php
// A page, or a resource (static): no badges in this menu
public function hasRelationNavigatorBadges(): bool
{
    return false;
}

// A relation manager (with InteractsWithRelationPage): its badge stays in
// the tab, not in the menu
protected static bool $hasRelationNavigatorBadge = false;
```

A relation manager whose tab badge is lazy in Filament
(`protected static ?bool $isBadgeLazyLoaded = true;`, or `$isBadgeDeferred` on
Filament 4.13) is lazy in the menu too, even with `'badges' => true`.

Menu views that cannot load badges later (package views published before
1.3, or presets of your own that render `$item->badge` themselves) get them
with the page, as before: nothing disappears.

**Keyboard**: from the search field, Down moves into the list; Up and Down
move between the pages, Enter opens one, Escape closes the menu.

### Shortcut and tooltip

The button that opens the menu has a tooltip with the shortcut, shown with
Mac or Windows/Linux keys. The shortcut opens the menu from anywhere on the
page, with the search field ready, like GitHub's repository switcher:
⌥ ⇧ R on a Mac, Alt Shift R
elsewhere. Change it in the config or per page:

```php
'shortcut' => 'mod+shift+p', // mod is ⌘ on a Mac and Ctrl elsewhere
```

```php
public function getRelationNavigatorShortcut(): ?string
{
    return null; // no shortcut on this page
}
```

It is built not to get in the way:

* it matches the physical key, so it works with any keyboard layout and with
  Option on a Mac (where ⌥⇧R types ‰);
* it does nothing while you type in a field;
* a shortcut of the panel's global search (`globalSearchKeyBindings()`) is
  never taken: the menu then has no shortcut;
* only the visible menu opens (breadcrumbs or small screens).

Supported keys: `alt`, `shift`, `ctrl`, `meta`, `mod` plus a letter, a digit
or `/ . , ;`.

### Page, resource or config

Every option has three levels. The page wins, then the resource, then the
config:

| Page method (static on the resource) | Config key |
|---|---|
| `getRelationNavigatorPreset(): string` | `menu.preset` |
| `isRelationNavigatorSearchable(): bool` | `menu.searchable` |
| `hasRelationNavigatorBadges(): bool` | `menu.badges` |
| `hasDeferredRelationNavigatorBadges(): bool` | `menu.badges` = `'lazy'` |
| `getRelationNavigatorShortcut(): ?string` | `menu.shortcut` |
| `hasRelationNavigatorMobileMenu(): bool` | `menu.mobile` |
| `hasRelationNavigatorRecordNavigation(): bool` | `record_navigation` |
| `shouldRelationNavigatorRecordNavigationFollowList(): bool` | `record_navigation_follows_list` |
| `shouldRedirectRelationNavigatorTabs(): bool` | `redirect_relation_tabs` |

```php
// On one page
public function isRelationNavigatorSearchable(): bool
{
    return false;
}
```

```php
// On a resource: the same method, static, for all its pages
public static function hasRelationNavigatorRecordNavigation(): bool
{
    return true;
}
```

### Small screens

Filament hides the breadcrumbs below 40rem. There the menu shows above the
page heading instead, on every page that uses `HasRelationNavigator`, with
the same preset options. Turn it off with `'mobile' => false`, or per page:

```php
public function hasRelationNavigatorMobileMenu(): bool
{
    return false;
}
```

### Translations

32 languages, with the same codes as Filament: Arabic, Bulgarian, Catalan,
Chinese (simplified and traditional), Czech, Danish, Dutch, English, Finnish,
French, German, Greek, Hebrew, Hungarian, Indonesian, Italian, Japanese,
Korean, Norwegian, Persian, Polish, Portuguese (Portugal and Brazil),
Romanian, Russian, Slovak, Spanish, Swedish, Turkish, Ukrainian and
Vietnamese. In right to left languages the previous and next arrows turn
around. Publish the translations to change them or add a language:

```bash
php artisan vendor:publish --tag=filament-relation-navigator-translations
```

### A preset of your own

Start from one of the package presets:

```bash
php artisan make:filament-relation-navigator-preset compact --from=github
```

It copies the preset to
`resources/views/filament/relation-navigator/compact.blade.php`. Register it
and change it as you like:

```php
'preset' => 'compact',
'presets' => [
    // ...
    'compact' => 'filament.relation-navigator.compact',
],
```

Any view name works as `preset` too. To change the package presets
themselves, publish their views:

```bash
php artisan vendor:publish --tag=filament-relation-navigator-views
```

A preset view receives:

| Variable             | Content                                                                 |
| -------------------- | ----------------------------------------------------------------------- |
| `$label`             | The last breadcrumb                                                     |
| `$items`             | The menu items: `key`, `label`, `url`, `icon`, `badge`, `badgeColor`, `isActive` |
| `$heading`           | "Switch page", translated                                               |
| `$isSearchable`      | Whether to show the search field                                        |
| `$hasSeparator`      | Whether to split record pages and relation pages in two blocks          |
| `$shortcut`          | The shortcut, or null                                                   |
| `$shortcutKeys`      | The shortcut keys to show: `['mac' => [...], 'other' => [...]]`         |
| `$searchPlaceholder` | "Find a page…", translated                                              |
| `$emptyLabel`        | "No pages found.", translated                                           |
| `$maxHeight`         | `menu.max_height`                                                       |

To give your button the tooltip and the shortcut, include
`filament-relation-navigator::menu.partials.trigger-attributes` inside its
tag. Each item also has `isRelationPage()`. To reuse the search field, the list
(with the separator and the keyboard navigation) and the "no results" line,
include `filament-relation-navigator::menu.partials.list` with `showCheck`.
