用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/umbraco/Umbraco-CMS-Backoffice-Skills --skill umbraco-modals命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | umbraco-modals |
| description | Implement modals in Umbraco backoffice using official docs |
| version | 1.0.0 |
| location | managed |
| allowed-tools | Read, Write, Edit, WebFetch |
A modal is a popup layer that darkens the surroundings and comes with a focus lock. The modal extension type is used to configure and present dialogs and sidebars within the Umbraco backoffice. Modals can be opened via routes (for deep-linking) or at runtime using the Modal Manager Context, and they use a token-based system for type-safe communication.
Always fetch the latest docs before implementing:
The Umbraco source includes working examples:
Custom Modal Location: /Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/custom-modal/
This example demonstrates a basic custom modal with token, element, and manifest.
Routed Modal Location: /Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/modal-routed/
This example demonstrates modals that can be opened via URL routing for deep-linking support.
If you need to explain these foundational concepts when implementing modals, reference these skills:
Context API: When implementing modal manager context, consumeContext patterns, or explaining how to open modals
umbraco-context-apiUmbraco Element: When implementing modal elements, explaining UmbLitElement, or creating modal components
umbraco-umbraco-elementState Management: When implementing modal data flow, modal values, or state management between modal and caller
umbraco-state-managementimport { UmbModalToken } from '@umbraco-cms/backoffice/modal';
export interface MyModalData {
title: string;
}
export interface MyModalValue {
confirmed: boolean;
}
export const MY_MODAL_TOKEN = new UmbModalToken<MyModalData, MyModalValue>(
'My.Modal',
{
modal: {
type: 'sidebar',
size: 'small',
},
}
);
import { html, customElement } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbModalExtensionElement } from '@umbraco-cms/backoffice/modal';
@customElement('my-modal')
export class MyModalElement extends UmbLitElement
implements UmbModalExtensionElement<MyModalData, MyModalValue> {
modalContext: any;
#handleSubmit() {
this.modalContext.updateValue({ confirmed: true });
this.modalContext.submit();
}
render() {
return html`
<umb-body-layout headline="${this.modalContext?.data?.title}">
<uui-box>
<p>Modal content here</>
;
}
}
;
export const manifests = [
{
type: 'modal',
alias: 'My.Modal',
name: 'My Modal',
element: () => import('./modal.element.js'),
},
];
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
import { MY_MODAL_TOKEN } from './modal-token.js';
// In your element:
constructor() {
super();
this.consumeContext(UMB_MODAL_MANAGER_CONTEXT, (context) => {
this._modalManager = context;
});
}
async openModal() {
const result = await this._modalManager?.open(this, MY_MODAL_TOKEN, {
data: { title: 'My Modal' }
});
if (result?.confirmed) {
console.log('User confirmed!');
}
}
That's it! Always fetch fresh docs, keep examples minimal, generate complete working code.