Header Menu

Header menu can be customized via methods defined in headerMenu namespace.

You have the ability to:

Custom button with callback

import { register } from "@adobe/uix-guest";

// ...

const guestConnection = await register({
    id: "my.company.extension-with-header-menu-button",
    methods: {
        headerMenu: {
            getButtons() {
                return [
                    {
                        id: "my.company.export-button",
                        label: "Export",
                        icon: 'Export',
                        onClick: () => {
                            console.log('Export button has been pressed.');
                        },
                    },
                ];
            },
        },
    },
});

The onClick callback is invoked when a user clicks on the button. It does not receive any arguments.

Header menu item

Custom button with sub menu

import { register } from "@adobe/uix-guest";

// ...

const guestConnection = await register({
    id: "my.company.extension-with-header-menu-button",
    methods: {
        headerMenu: {
            async getButtons() {
                return [
                    {
                        id: "my.company.export-button",
                        label: "Export",
                        icon: 'Export',
                        subItems: [
                            {
                                id: 'xml',
                                label: 'XML',
                                onClick: async () => {
                                    const contentFragment = await guestConnection.host.contentFragment.getContentFragment();
                                    // ...
                                },
                            },
                            {
                                id: 'csv',
                                label: 'CSV',
                                onClick: async () => {
                                    const contentFragment = await guestConnection.host.contentFragment.getContentFragment();
                                    // ...
                                },
                            },
                        ],
                    },
                ];
            },
        },
    },
});

Header menu item with submenu

API Reference

Button API

Field
Type
Required
Description
id
string
✔️
Must be unique across all extensions. Consider adding a vendor prefix to this field
label
string
✔️
Button label that will be visible on UI
icon
string
Name of a React-Spectrum workflow icon
variant
cta <br/> primary <br/> secondary <br/> negative <br/> action
The visual style of the button
subItems
array
A list with sub menu items.
onClick
callback(): void
✔️
A callback for a button onClick event
Field
Type
Required
Description
id
string
✔️
Must be unique across the current button sub menu
label
string
✔️
Button label that will be visible on UI
icon
string
Name of a React-Spectrum workflow icon
onClick
callback(): void
✔️
A callback for a button onClick event

Extension Points API

More details about Extension Points APIs.