Custom Modals
New modals can be added to the system via the extension registry.
Create a modal element
import { customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbModalExtensionElement } from '@umbraco-cms/backoffice/modal';
import type { UmbModalContext } from '@umbraco-cms/backoffice/modal';
import type { MyModalData, MyModalValue } from './my-modal.token.js';
@customElement('my-dialog')
export class MyDialogElement
extends UmbLitElement
implements UmbModalExtensionElement<MyModalData, MyModalValue> {
@property({ attribute: false })
modalContext?: UmbModalContext<MyModalData, MyModalValue>;
@property({ attribute: false })
data?: MyModalData;
private _handleCancel() {
this.modalContext?.submit();
}
private _handleSubmit() {
this.modalContext?.updateValue({ myData: 'hello world' });
this.modalContext?.submit();
}
render() {
return html`
<div>
<h1>${this.modalContext?.data.headline ?? 'Default headline'}</h1>
<button @click=${this._handleCancel}>Cancel</button>
<button @click=${this._handleSubmit}>Submit</button>
</div>
`;
}
}
export const element = MyDialogElement;Declare an Extension Manifest
Create a modal token
Open the modal
Last updated
Was this helpful?