Toolbar Actions

Toolbar actions add buttons to the UmbNav item toolbar that appears when hovering over menu items in the backoffice.

Basic Registration

import { UmbNavExtensionRegistry } from '/App_Plugins/UmbNav/dist/api.js';

UmbNavExtensionRegistry.registerToolbarAction({
    alias: 'my-custom-action',
    label: 'Star Item',
    icon: 'icon-favorite',
    onExecute: (item, context) => {
        console.log('Action clicked on:', item.name);
    }
});

Interface Definition

interface UmbNavToolbarAction {
    /** Unique identifier for this action */
    alias: string;

    /** Display label (shown as tooltip) */
    label: string;

    /** Icon name (UUI icon) */
    icon: string;

    /** Position: 'start' | 'end' | number */
    position?: 'start' | 'end' | number;

    /** Visibility check function */
    isVisible?: (item: ModelEntryType, config: UmbPropertyEditorConfigProperty[]) => boolean;

    /** Handler when clicked */
    onExecute: (item: ModelEntryType, context: UmbNavActionContext) => void | Promise<void>;
}

Action Context

The context object provides methods to interact with UmbNav:

Examples

Simple Notification

Toggle a Property

Conditional Visibility

Only show for specific item types:

Only show when a specific configuration is enabled:

Async Operations

Opening a Modal

Use existing UmbNav modals:

Use Umbraco's built-in modals:

Position Control

Removing Items

Complex Business Logic

Unregistering Actions

Getting Registered Actions

Available Icons

UmbNav uses Umbraco's UUI icon set. Common icons include:

  • icon-favorite - Star

  • icon-settings - Settings gear

  • icon-edit - Pencil

  • icon-delete - Trash

  • icon-add - Plus

  • icon-remove - Minus

  • icon-check - Checkmark

  • icon-alert - Warning

  • icon-info - Information

  • icon-lock - Lock

  • icon-unlocked - Unlocked

  • icon-eye - Visible

  • icon-eye-slash - Hidden

  • icon-link - Link

  • icon-unlink - Unlink

  • icon-picture - Image

  • icon-document - Document

  • icon-folder - Folder

Best Practices

  1. Use unique aliases - Prefix with your package name

  2. Provide meaningful labels - Shown as tooltips

  3. Handle errors gracefully - Don't break the UI

  4. Check visibility - Only show when relevant

  5. Keep actions fast - Show loading states for slow operations

  6. Preserve item data - Use spread operator when updating

Last updated

Was this helpful?