DEV Community

Kevin Jump
Kevin Jump

Posted on • Updated on

Early Adopter's guide to Umbraco v14 - Header apps and modal dialogs

One thing we are being promised with the new Umbraco backoffice is flexability, and the ability to customize things we couldn't really customeize before.

One of those places is the header bar - specifically the buttons to the right.

umbraco header bar

As with other posts, the code used in this series is avalible on github

Header bar buttons.

Guess what. you need to define a manifest:

const header : ManifestHeaderApp = {

    type: 'headerApp',
    alias: '',   
    name: 'time app',
    js: () => import('./time-header-element.js'),
    weight: 850,
    meta: {
        label: 'time',
        icon: 'icon-alarm-clock',
        pathname: 'time'
Enter fullscreen mode Exit fullscreen mode

Header button element

like other bits of the UI, you then need to define your header element in the file you imported into the manifest.

export class TimeHeaderAppElement extends UmbElementMixin(LitElement) {

    #onTime() {
       // do something when you click

    render() {
        return html`
            <uui-button @click=${this.#onTime}
                <uui-icon name="icon-alarm-clock"></uui-icon>

    static styles = css`
        uui-button {
            font-size: 18pt;
            --uui-button-background-color: transparent;
Enter fullscreen mode Exit fullscreen mode

and this gives you a icon in the header (the clock is ours)

Image description

but at the moment, nothing happens when you click on it, so lets add a simple popup when you do.

popup modal

In Umbraco v8-13 you could use the overlayservice to open up a popup dialog on the page, with Umbraco v14 these dialogs are part of the whole modal domain.

We will probibly go into opening modals, in more depth later on, but for now lets open a simple popup

A modal is again a umbraco element

export class TimeHeaderModalElement extends UmbModalBaseElement {

    #handleClose() {

    render() {
        return html`
            <uui-dialog-layout class="uui-text"
                headline="a modal dialog box">
                <p>Some modal things go here</p>

                <uui-button slot="actions" id="close" label="Close"
                    look='primary'  color='danger'

Enter fullscreen mode Exit fullscreen mode

wrapping our html in a <uui-dialog-layout> tag will give it more of a popup vibe! .

you also need to register your modal with a manifest.

const modal: ManifestModal = {
    type: 'modal',
    alias: 'time.header.modal',
    name: 'time header modal',
    js: () => import('./time-header-modal.js'),
Enter fullscreen mode Exit fullscreen mode

Calling th modal

modals can be opened using the ModalManagerContext, if you pass the alias of your modal, then it opens.

so in our #onTime method above we can add:

#onTime() {
    this.consumeContext(UMB_MODAL_MANAGER_CONTEXT_TOKEN, (manager) =>{'time.header.modal', {});
    } )
Enter fullscreen mode Exit fullscreen mode

And we get a modal!

A modal popup

Closing the modal

the modal itself is responsible for closing the popup, if you don't add that in, you have to reload the browser to break out!

you might have noticed our modal element extended UmbModalBaseElement this element already has a modalContext so we can close the modal by calling reject.

Enter fullscreen mode Exit fullscreen mode

As with other posts, the code used in this series is avalible on github

So simple modal's are easy, but what about complex ones....

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more