Anvil Community Forum

Custom component in design mode

I have created a custom component, added a label, added a property, and linked the property to the label text using data binding. When I add the custom component to a new form and set the property, the label text is updated as expected at runtime, but it is not in the IDE.

Is it possible to execute some code at design time (and I would be responsible for writing that code) or automatically resolving the data binding inside the IDE (and this would be a feature request for the Anvil team)?

6 Likes

I’m bumping this topic because I’m running into the same issue.

I created a sample app to illustrate.

https://anvil.works/build#clone:T6GU34QGIVJ6GA5N=QFA7NMYBBUEAGS6QZE4CQXGG

In this example, my custom headline component displays the default text “Headline” and “Sub head” in the designer instead of the value of the property. It does display correctly when the app is run.

How do I make this component play nicely with the designer?

4 Likes

Bumping this as well - I need to be able to change a label’s text on a custom component according to a property value, as I may have many of them on a page.

I actually thought this used to work, but I guess not.

1 Like

If I have a custom component that has a label called “label_title” and I set the value to “First Name” in the UI, when I look at the custom component on the screen, I’d like to see the set value of “First Name” rather than “label_title”

:slight_smile:

2 Likes

I can’t explain how, myself, but @stucork has achieved this for some Anvil Extras components:

I guess it has something to do with this code: anvil-extras/js/designer_components at main · anvilistas/anvil-extras · GitHub

Anyway, this is not a substitute for Anvil just making this work automatically, but it’s technically possible already if you want it badly enough.

I would love to see Anvil dynamically update the Custom Components in the designer as well. This is something I have found somewhat frustrating too, because it makes visually laying out my forms more difficult. Also, I would love to see the ability to have a drop down selector for properties in a Custom Component (i.e., instead of having to type in “small” for spacing_below, we could have a selection similar to native components).

There is now an Anvil Extras README explaining how.

1 Like