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
import { Dock } from '@ng-native/device';
import { TrayIcon } from '@ng-native/components';
Template
<tray-icon> once TrayIcon is in the component's imports
Inject
inject(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. On Linux image names an icon in the icon theme, the app's own icon stands in without one, and sfSymbol is not drawn. A menu-bar-only app pairs it with provideMainWindow({ autoOpen: false }); see Windows.

Reference

Dockservice@ng-native/device
import { 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/components
import { 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

title
string

sfSymbol
string

An SF Symbol, drawn to follow the menu bar's light or dark appearance.

image
string

An image asset of the app's own.

tooltip
string

Outputs

press
void

Angular components as native iOS and Android views, built and shipped with Expo.

An alpha. MIT licensed. Sponsor its development.

An independent project, not affiliated with or endorsed by Google, the Angular team or Expo. Angular is a trademark of Google LLC.