Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

block construction with key value

Avatar

Level 2

Hello, I have the following question about building blocks for the Universal Editor. I want to create a block that has the following template.

"models": [
{
"id": "color",
"fields": [
{
"component": "text",
"valueType": "string",
"name": "color",
"label": "Color (Hex Code)"
}
]
}
]

Currently, when you render the component once it's complete, it looks like this

<div>
<div>#FFFFFF</div>
</div>

That is, just the value, I would like it to arrive as a key value
<div>
<div>color</div>
<div>#FFFFFF</div>
</div>

I'm asking because, when using it, for example, from Google Docs, I believe the key and value can be obtained. I'm currently using the resource type: core/franklin/components/block/v1/block.

Thank you very much if anyone can help me with this question. Best regards.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @LidermanGiraldoEscobar 

The "key-value" option works well for blocks and container blocks, but not for block items.

 

In many cases, it is recommended to decorate the rendered semantic markup, add CSS class names, add new nodes or move them around in the DOM, and apply styles.

 

In other cases however, the block is read as a key-value pair-like configuration, which can be achieved by using "key-value": true property in the component-definition.json

Arun Patidar

AEM LinksLinkedIn

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @LidermanGiraldoEscobar 

In google docs all the content in the blocks rendered in the page, e.g. Label and Value

But in case of Universal Editor, only the values are rendering based on field type.

Arun Patidar

AEM LinksLinkedIn

Hello @arunpatidar 

I have a small question: If this documentation mentions key-value pairs, in what case would they be used? I'm a little confused about this topic.

https://www.aem.live/developer/component-model-definitions

1.png

2.png


thank you so much!




Avatar

Correct answer by
Community Advisor

Hi @LidermanGiraldoEscobar 

The "key-value" option works well for blocks and container blocks, but not for block items.

 

In many cases, it is recommended to decorate the rendered semantic markup, add CSS class names, add new nodes or move them around in the DOM, and apply styles.

 

In other cases however, the block is read as a key-value pair-like configuration, which can be achieved by using "key-value": true property in the component-definition.json

Arun Patidar

AEM LinksLinkedIn

Avatar

Administrator

@LidermanGiraldoEscobar Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!



Kautuk Sahni

Avatar

Administrator

@LidermanGiraldoEscobar Did you find the suggestion helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!



Kautuk Sahni