Item Types

UmbNav supports three built-in item types: Document, Link, and Title. You can register additional item types for specialized use cases.

Basic Registration

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

UmbNavExtensionRegistry.registerItemType({
    type: 'button',
    label: 'Button',
    icon: 'icon-hand-pointer',
    allowChildren: false
});

Interface Definition

interface UmbNavItemTypeRegistration {
    /** Unique type identifier */
    type: string;

    /** Display label in the UI */
    label: string;

    /** Icon for this type */
    icon: string;

    /** Whether items of this type can have children */
    allowChildren?: boolean;

    /** Custom render function for display */
    render?: (item: ModelEntryType) => TemplateResult;

    /** Modal token to open when editing */
    editModalToken?: unknown;

    /** Modal token to open when creating */
    createModalToken?: unknown;
}

Examples

Simple Custom Type

A basic custom type without special rendering:

Type with Custom Rendering

Custom display in the item list:

Type with Custom Modal

For types that need special editing:

Call-to-Action Button Type

Mega Menu Section Type

Working with Custom Types in Views

On the frontend, check the item type and render accordingly:

Backend Support

To fully support custom types in the backend, you may need to extend the enum or handle them as custom strings:

Unregistering Item Types

Getting Registered Types

Best Practices

1. Use Meaningful Type Names

2. Provide Clear Icons

Choose icons that represent the type's purpose:

3. Consider Child Support

Think about whether items of this type should support nesting:

4. Handle Missing Data

Your render function should handle undefined values:

5. Match UmbNav Styling

Use consistent styling with the rest of UmbNav:

Limitations

  • Custom types are stored as strings in the item's itemType property

  • The backend UmbNavItemType enum doesn't automatically include custom types

  • You may need to handle custom types specially in your rendering code

  • Modals for custom types must be registered separately with Umbraco

Last updated

Was this helpful?