item
Best practices
- Naming an item: Give an
item
a short, concise name. Use action words only if the item triggers an action. - Icons: Really consider the role that icons play. They are meant to supplement communication and should almost be able to portray a concept without accompanying text - so choose them wisely.
- Apply icons to all child items within one group, or none.
main.view.xml
<context-menu>
<item label="Video Tutorials" icon="fa-play" on-press="$:navigate.link('video_tutorials')" />
<item label="FAQ" icon="fa-question-circle" on-press="$:navigate.link('faq')" />
<!-- A `divider` element will automatically be added to separate the above items -->
<!-- from non-customizable app items, e.g. 'Diagnostics' -->
</context-menu>

Optional
Type:
string
Default: unset
The icon to display on the
item
, it will be placed on the left of the label
by default. The icon
can be a Font Awesome icon, an Ionicons icon or a png icon asset.main.view.xml
<context-menu>
<item label="FAQ" icon="fa-question-circle" on-press="$:navigate.link('faq')" />
</context-menu>
Optional
Default: Unset
The text that appears on the
item
to describe it.main.view.xml
<context-menu>
<item label="FAQ" icon="fa-question-circle" on-press="$:navigate.link('faq')" />
</context-menu>
Note: When constructing an item from JavaScript/TypeScript, use
onPress
, i.e.:main.js
function buildContextMenuItem() {
return component.contextMenuItem({
label= "Video Tutorials",
icon="fa-play",
onPress:function() {
navigate.link("video_tuts");
}
})
}
Optional
Default: unset
Construct a
context-menu
item
from JavaScript/TypeScript.main.view.xml
<context-menu>
<item from-js="$:buildContextMenuItem()">
</context-menu>
main.js
function buildContextMenuItem() {
return component.contextMenuItem({
label= "Video Tutorials",
icon="fa-play",
onPress:function() {
navigate.link("video_tuts");
}
})
}
Optional
Type:
boolean
Default:
false
Set to
true
to ensure that no required input fields in the current view are empty before performing the on-press
action.Last modified 1yr ago