How to set html attributes dynamically?

What is the correct format to set the HTML attributes of an element dynamically, for example I want to set several attributes dynamically.

Captura de Tela 2024-07-21 às 18.06.40

I tried to map an object but it didn’t work. I can only do so if the attribute and value are individual. However, in a component I will need to define it dynamically depending on the properties selected in the component.

I think it could be something like:
[{key: "data-attribute", value:"first-value"}, ..] this was the structure that WeWeb used fro Supabase metadata as well, so I think this might be the convention across the app.

Did not work.

@luka @Alexis
How can I do this?

I think we have some inconsistency there, it’s probably

[{name: "attr-key", value:"attr-value"}]

It worked out. Thanks!

1 Like