Modals
A modal is a popup layer that darkens the surroundings and comes with a focus lock. There are two types of modals: "dialog" and "sidebar".
Modal Types
Open a Modal
Directly open via the Open Modal method
import { customElement, html } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { MY_MODAL_TOKEN } from './my-modal.token.js';
import { umbOpenModal } from '@umbraco-cms/backoffice/modal';
@customElement('my-element')
class MyElement extends UmbLitElement {
override render() {
return html`
<uui-button look="primary" label="Open modal" @click=${this._openModal}></uui-button>
`;
}
private async _openModal() {
const returnedValue = await umbOpenModal(this, MY_MODAL_TOKEN, {
data: {
headline: "My modal headline",
},
}).catch(() => undefined);
}
}
declare global {
interface HTMLElementTagNameMap {
'my-element': MyElement;
}
}Directly open via the Modal Manager Context
Modal Route Registration
Make a custom Modal
Last updated
Was this helpful?