Not sure, but could you maybe create a role and either add that to the component, or if you want to do all components inside a container, add the role to the container instead and make the CSS target that and its contents?
Basically you prefix the role name with “anvil-role-” in the CSS definition.
now drag a Label onto the form, and under “Appearance” in the properties, you will see a drop down called “Role”. Your new role should be the only entry. Choose that.
You should now see your label change background colour. That’s a trivial example, but it shows how they work.
They green one adds 50px to the normal padding, but the yellow is not able to remove the 15px padding of its parent. The two labels and the text box are on a form. I tried applying the roles to the form, but nothing changed.
I would like to control the gap highlighted in red.
If I inspect the element in Chrome I find out that the culprit is a <div class="col-padding"> that wraps each Anvil component, and if I change the definition of .col-padding from padding: 0px 15px; to padding: 0px 5px; the problem is solved.
The problem seems to be that roles affect the content of the div, not the div itself.