I was able to make something close to Approved Color picker, but using Umbraco Content nodes as data source + Custom Component List in Contentment.
Main difference is that Contentment disable pointer events, so hover and focus style on <uui-color-swatch> doesn’t work, but if disabled it cause double focus on wrapping <button> + <uui-color-swatch>.
At top Approved Color Picker and at bottom Contentment property editor:
I wonder if it could disable wrapping <button> element, when developer handle implementation of selected state?
I also noticed on selection, it seems to refresh the component/view, but not sure if this is a requirement to work?
Anyway I have the following implementation:
import type { ContentmentDataListItemUiElement, ContentmentListItem } from '../types.js';
import { customElement, html, nothing, property, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbDocumentDetailRepository } from '@umbraco-cms/backoffice/document';
import { getGuidFromUdi } from '@umbraco-cms/backoffice/utils';
@customElement('contentment-data-list-item-ui-color-swatch')
export class ContentmentDataListItemUiColorSwatchElement extends UmbLitElement implements ContentmentDataListItemUiElement {
@property({ attribute: false })
item?: ContentmentListItem;
@state()
private _color = '';
@state()
private _label = '';
#documentRepository = new UmbDocumentDetailRepository(this);
#documentUnique = '';
override firstUpdated() {
this.#documentUnique = getGuidFromUdi(this.item?.value ?? '') ?? '';
this.#getDocumentData();
}
async #getDocumentData() {
console.log("item", this.item);
if (!this.item?.value)
return;
const { data } = await this.#documentRepository.requestByUnique(this.#documentUnique);
if (!data) return;
const prop = data.values.find(x => x.alias === 'color');
if (prop) {
this._color = prop.value as string;
this._label = data.variants[0].name;
}
}
override render() {
if (!this.item) return nothing;
return html`<uui-color-swatch
color="${this._color ?? ''}"
value="${this._color ?? ''}"
selectable
?selected="${this.item?.selected ?? undefined}"
.showLabel=${true}>
<span slot="label">${this._label ?? ''}</span>
</uui-color-swatch>`;
}
}
export { ContentmentDataListItemUiColorSwatchElement as element };
declare global {
interface HTMLElementTagNameMap {
'contentment-data-list-item-ui-color-swatch': ContentmentDataListItemUiColorSwatchElement;
}
}
and furthermore thesee styles:
List styles
display: grid; grid-template-columns: repeat(3, minmax(120px, 0fr)); grid-gap: 0.4rem;
List item styles
border: none; outline: none;

