You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 14/umbraco-cms/customizing/extending-overview/extension-types/menu.md
+193-9Lines changed: 193 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,37 +4,221 @@
4
4
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
For this TypeScript example we used a [Backoffice Entry Point](../../extending-overview/extension-types/backoffice-entry-point) extension to register the manifests
In this section, you can learn how to add custom Menu Items to your Umbraco backoffice Menu.
63
+
64
+
### Manifest
65
+
66
+
To add custom menu items, you can define a single MenuItem manifest and link an element to it. In this element, you can fetch the data and render as many menu items as you want based on that data.
67
+
68
+
The code snippets below show how to declare a new menu item using JSON or TypeScript.
69
+
70
+
{% tabs %}
71
+
72
+
{% tab title="JSON" %}
73
+
74
+
We can create the manifest using JSON in the `umbraco-package.json`.
75
+
76
+
```json
24
77
{
25
78
"type": "menuItem",
26
79
"alias": "My.MenuItem",
27
80
"name": "My Menu Item",
81
+
"element": "./menu-items.ts",
28
82
"meta": {
29
83
"label": "My Menu Item",
30
84
"menus": ["My.Menu"]
31
85
}
32
86
}
33
87
```
34
88
35
-
### **Tree Menu Item**
89
+
{% endtab %}
90
+
91
+
{% tab title="TypeScript" %}
92
+
93
+
The manifest can also be written in TypeScript.
94
+
95
+
For this TypeScript example we used a [Backoffice Entry Point](../../extending-overview/extension-types/backoffice-entry-point) extension to register the manifests
#### Rendering menu items with Umbraco's UI menu item component
122
+
123
+
To render your menu items in Umbraco, you can use the [Umbraco UI Menu Item component](https://uui.umbraco.com/?path=/docs/uui-menu-item--docs). This component allows you to create nested menu structures with a few lines of code.
124
+
125
+
By default, you can set the `has-children` attribute to display the caret icon indicating nested items. It will look like this: `?has-children=${bool}`.
126
+
127
+
**Example:**
128
+
129
+
```tsx
130
+
<uui-menu-itemlabel="Menu Item 1"has-children>
131
+
<uui-menu-itemlabel="Nested Menu Item 1"></uui-menu-item>
132
+
<uui-menu-itemlabel="Nested Menu Item 2"></uui-menu-item>
133
+
</uui-menu-item>
134
+
```
135
+
136
+
#### Custom menu item element example
137
+
138
+
You can fetch the data and render the menu items using the Lit element above. By putting the result of the fetch in a `@state()`, we can trigger a re-render of the component when the data is fetched.
0 commit comments