Dock and tray
On macOS an app has a Dock icon, and can put icons in the status area at the right of the menu bar.
On Linux tray icons go in the panel's status area, as StatusNotifierItems, where the desktop runs a
StatusNotifierWatcher (KDE Plasma, and GNOME with the AppIndicator extension), and there is no Dock.
On iOS and Android neither exists. Where one is missing its available() is false, and every
call does nothing.
import { Dock } from '@ng-native/device';
import { TrayIcon } from '@ng-native/components';
<tray-icon> once TrayIcon is in the component's importsinject(Dock)Platforms of Dock. Available on macOS. Absent on Linux, iPadOS, iPhone, Android and Web host, where available() is false.
Platforms of <tray-icon>. Available on macOS and Linux (while a StatusNotifierWatcher runs). Absent on iPadOS, iPhone, Android and Web host, where available() is false.
The Dock
import { Dock } from '@ng-native/device';
const dock = inject(Dock);
dock.setMenu([{ label: 'New Window', select: () => windows.open(Editor) }]);
const stop = dock.bounce({ critical: true });setMenu puts items above the ones macOS adds to the Dock icon's menu, and null takes them away.
bounce bounces the icon once, or with critical until the app comes to the front, and answers a
function that stops it. The Dock badge is the Notifications badge
count, as an app icon's is on iOS: Notifications.setBadge(3).
Tray icons
A <tray-icon> shows an icon for as long as the element is there. Its <menu-item>s are the menu a
click opens; with none, a click fires (press).
<tray-icon sfSymbol="timer" [title]="remaining()" tooltip="Focus timer">
<menu-item label="Pause" (select)="pause()" />
<menu-separator />
<menu-item menuRole="quit" label="Quit" />
</tray-icon>sfSymbol draws a symbol that follows the menu bar's light or dark appearance; image names an
image asset of the app's own. icon takes the picture as one value, as
<native-button> does: { sfSymbol }, or an icon's SVG
markup, { svg }, such as an @ng-icons icon, which macOS draws as it draws a symbol. On Linux
image names an icon in the icon theme, the app's own icon stands in without one, and sfSymbol is
not drawn. An SVG icon is drawn as a picture of its own, and its menu items' SVG icons too: the
panel draws a picture as it is given, so the icon is light on GNOME, whose top bar is dark in either
style, and elsewhere, as on KDE Plasma, whose panel follows the colour scheme, light in the dark
style and dark in the light one. A menu-bar-only app pairs it with
provideMainWindow({ autoOpen: false }); see Windows.
Reference
Dockservice@ng-native/deviceimport { Dock } from '@ng-native/device';Methods
setMenu(entries: readonly MenuEntry[] | null): void Show entries in the Dock icon's menu, above the items macOS adds (Options, Show All Windows, Hide, Quit); an empty list or null takes them away. Items are MenuItemModel s, as a <menu-item> registers them.
bounce(options: { critical?: boolean } = {}): () => void Bounce the Dock icon until the app comes to the front: once, or with critical until then. Nothing while the app is in front. Answers the function that stops it.
tray-iconcomponent@ng-native/componentsimport { TrayIcon } from '@ng-native/components';and add TrayIcon to the component's imports An icon in the macOS menu bar's status area, for as long as the element is there. Its <menu-item> s are the menu a click opens; with none, a click fires (press) . On iOS and Android nothing is drawn.
Inputs
titlestringsfSymbolstringAn SF Symbol, drawn to follow the menu bar's light or dark appearance.
iconButtonIcon The picture as a ButtonIcon : { sfSymbol } , or an icon's SVG markup, { svg } , such as an @ng-icons icon, drawn as a symbol is. sfSymbol wins over it.
imagestringAn image asset of the app's own.
tooltipstringOutputs
pressvoid