---
url: /filament-relation-navigator/v1.4/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' => true,       // the relation managers' badges; 'lazy' loads them when the menu opens
    '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`.

### Deferred badges

Badges run the same queries as the tab badges. With `'badges' => 'lazy'` the
page renders without them, and the menu loads them in one request when it
opens. If you published the package views, update
`menu/partials/list.blade.php` first.

**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` |
| `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

English, Italian, Spanish, German, French, Brazilian Portuguese and Dutch.
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`.
