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 '@umbraco-community/umbnav/api';

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;

    /** Default values to apply when creating an item of this type */
    defaultValues?: Partial<ModelEntryType>;

    /** 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;
}

Default Behavior (No Modal)

By default, custom item types are added directly when their button is clicked — no modal dialog is opened. The item is created using the defaultValues from the registration.

When no editModalToken is provided:

  • The item's name is displayed as plain text (not a clickable link)

  • The Edit button is hidden from the toolbar

  • The item can still be deleted and reordered via drag-and-drop

This is ideal for simple item types like dividers or separators that don't need user input.

To enable editing, provide an editModalToken (and optionally a createModalToken) — see Type with Custom Modal below.

Examples

Simple Custom Type

A basic custom type that is added directly without a modal:

Since no editModalToken is provided, clicking "Add Divider" immediately creates the item with the specified defaultValues. The item name displays as plain text and has no edit button.

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?