Item Slots

Item slots allow you to inject custom content at specific positions within UmbNav menu items in the backoffice.

Basic Registration

import { UmbNavExtensionRegistry } from '/App_Plugins/UmbNav/dist/api.js';
import { html } from '@umbraco-cms/backoffice/external/lit';

UmbNavExtensionRegistry.registerItemSlot({
    alias: 'my-badge',
    position: 'after-name',
    render: (item, config) => html`<span class="my-badge">New</span>`
});

Interface Definition

interface UmbNavItemSlot {
    /** Unique identifier for this slot */
    alias: string;

    /** Position within the item */
    position: 'before-name' | 'after-name' | 'before-toolbar' | 'after-toolbar';

    /** Render function returning Lit TemplateResult */
    render: (item: ModelEntryType, config: UmbPropertyEditorConfigProperty[]) => TemplateResult;

    /** Optional visibility check */
    isVisible?: (item: ModelEntryType, config: UmbPropertyEditorConfigProperty[]) => boolean;
}

Slot Positions

UmbNav items have four slot positions:

Position
Location
Common Uses

before-name

Before the item name

Status indicators, priority markers

after-name

After the item name

Badges, labels, counters

before-toolbar

Before toolbar buttons

Additional action areas

after-toolbar

After toolbar buttons

Status icons, info buttons

Examples

Simple Badge

Item Type Icon

Children Counter

Visibility Status

Unpublished Warning

SEO Score Indicator

Interactive Slot

Slots can include interactive elements:

Multiple Slots Combined

Register multiple slots for a cohesive extension:

Styling Slots

Using Inline Styles

Using UUI Components

Using CSS Custom Properties

Umbraco's UUI provides CSS custom properties:

Unregistering Slots

Getting Registered Slots

Best Practices

  1. Keep slots lightweight - They render for every item

  2. Use visibility checks - Don't render unnecessary content

  3. Match UmbNav styling - Use UUI components and CSS variables

  4. Handle missing data - Check for null/undefined

  5. Stop event propagation - For interactive elements, prevent bubbling

  6. Use unique aliases - Prefix with your package name

Performance Considerations

Slots render for every visible item. For expensive operations:

Last updated

Was this helpful?