Extended color field Structure preview

:waving_hand: Hello!

I’m extending color fields in a plugin to set default values for theme styling, using this approach: Dynamic default number field - #2 by texnixe

Which works great, except the field preview within a structure field displays as text (and not a color preview).

Is there a easy way to repurpose or apply the core color field preview in this context?

Many thanks in advance!

You can re-use the original component like this, in this example, my custom field is called colour instead of color:

panel.plugin("my/plugin", {
    fields: {
        colour: {
            extends: "k-color-field"
        }
    },
    components: {
        'k-colour-field-preview': {
            extends: 'k-color-field-preview'
        },
    }
});

Awesome, thank you Sonja!