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
In this section, you can learn how to register and create a custom Menu for the Umbraco backoffice.
12
+
13
+
### Manifest
14
+
15
+
The manifest file can be created using either JSON or Typescript. Both methods are shown below.
16
+
17
+
{% tabs %}
18
+
19
+
{% tab title="Json" %}
20
+
21
+
We can create the manifest using json in the umbraco-package.json.
22
+
10
23
```json
11
24
{
12
25
"type": "menu",
13
26
"alias": "My.Menu",
14
27
"name": "My Menu"
15
28
}
16
29
```
30
+
{% endtab %}
31
+
32
+
{% tab title="Typescript" %}
33
+
34
+
The manifest can also be written in TypeScript.
35
+
36
+
For this typescript example we used a [Backoffice Entry Point](../../extending-overview/extension-types/backoffice-entry-point) extension to register the manifests
For adding custom menu items we can define a single MenuItem manifest and link an element to it. In this element we can fetch the data and render as many menu items as we want based on that data.
60
+
## Creating a custom menu items
61
+
62
+
In this section, you can learn how to add custom Menu Items to your Umbraco backoffice Menu.
41
63
42
-
### JSON Manifest
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.
43
75
44
76
```json
45
77
{
@@ -54,7 +86,15 @@ For adding custom menu items we can define a single MenuItem manifest and link a
54
86
}
55
87
```
56
88
57
-
### Typescript Manifest
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
76
122
77
-
To render your menu items in Umbraco, you can make use of the powerful [Umbraco UI Menu Item component](https://uui.umbraco.com/?path=/docs/uui-menu-item--docs). This component allows you to easily create nested menu structures with just a few lines of code.
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.
78
124
79
-
To display the caret icon indicating nested items, you can set the `has-children` attribute dynamically like this: `?has-children=${bool}`.
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}`.
80
126
81
127
**Example:**
82
128
@@ -89,9 +135,9 @@ To display the caret icon indicating nested items, you can set the `has-children
89
135
90
136
#### Custom menu item element example
91
137
92
-
Using this Lit element we can fetch the data and render the menu items. By putting the result of the fetch in a `@state()`, we can trigger a re-render of the component when the data is fetched.
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