# FMenu

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/menu](https://docs.univer.ai/zh-CN/reference/facade/menu)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/menu.md](https://docs.univer.ai/zh-CN/reference/facade/menu.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/menu.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/menu.mdx)

---

This is the builder for adding a menu to Univer. You shall never construct this
class by yourself. Instead, call `createMenu` of `FUniver` to create a instance.

Please notice that until the `appendTo` method is called, the menu item is not added to the UI.

Please note that this menu cannot have submenus. If you want to
have submenus, please use `FSubmenu`.

## Access

Access through:

* [`FUniver.createMenu()`](https://docs.univer.ai/zh-CN/reference/facade/univer.md#createmenu)

## Setup

Register [`@univerjs/ui`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/ui.md) or a preset that includes it. In plugin mode, import `@univerjs/ui/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/zh-CN/guides/sheets/getting-started/facade.md).

## `@univerjs/ui`

### `FMenu.appendTo`

Append the menu to any menu position on Univer UI.

```typescript
appendTo(path: string | string[]): void
```

**Parameters**

* `path` — Required. Some predefined path to append the menu. The paths can be an array,
  or an array joined by `|` separator. Since lots of submenus reuse the same name,
  you may need to specify their parent menus as well.

**Examples**

```ts
// This menu item will appear on every `contextMenu.others` section.
univerAPI
  .createMenu({
    id: 'custom-menu-id-1',
    title: 'Custom Menu 1',
    action: () => {
      console.log('Custom Menu 1 clicked')
    },
  })
  .appendTo('contextMenu.others')

// This menu item will only appear on the `contextMenu.others` section on the main area.
univerAPI
  .createMenu({
    id: 'custom-menu-id-2',
    title: 'Custom Menu 2',
    action: () => {
      console.log('Custom Menu 2 clicked')
    },
  })
  .appendTo(['contextMenu.mainArea', 'contextMenu.others'])
```

**Package:** [`@univerjs/ui`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/ui.md) · [Type definitions](https://unpkg.com/@univerjs/ui@1.0.0-rc.0/lib/types/facade/f-menu-builder.d.ts)

### `FMenu.MenuManagerPosition`

```ts
MenuManagerPosition: typeof MenuManagerPosition
```

**Package:** [`@univerjs/ui`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/ui.md) · [Type definitions](https://unpkg.com/@univerjs/ui@1.0.0-rc.0/lib/types/facade/f-menu-builder.d.ts)

### `FMenu.RibbonPosition`

```ts
RibbonPosition: typeof RibbonPosition
```

**Package:** [`@univerjs/ui`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/ui.md) · [Type definitions](https://unpkg.com/@univerjs/ui@1.0.0-rc.0/lib/types/facade/f-menu-builder.d.ts)

### `FMenu.RibbonStartGroup`

```ts
RibbonStartGroup: typeof RibbonStartGroup
```

**Package:** [`@univerjs/ui`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/ui.md) · [Type definitions](https://unpkg.com/@univerjs/ui@1.0.0-rc.0/lib/types/facade/f-menu-builder.d.ts)
