Hi everyone,
I’ve run into a limitation with Boolean HTML attributes when working with Bricks Components.
For example, a reusable radio option should be optionally preselected via a Component Property:
<!-- selected -->
<input type="radio" name="animal" value="dog" checked>
<!-- not selected -->
<input type="radio" name="animal" value="dog">
Ideally, a Toggle Property could add checked when enabled and completely remove the attribute when disabled.
Using something like checked="false" doesn’t work, since Boolean HTML attributes are considered active simply by being present.
I also tried solving this with Component Variants, but as far as I can see, variants can only change styling and cannot set different HTML attributes.
Currently, the only workaround I found is using a Text Property and manually entering checked. This works, but isn’t particularly clean for reusable components.
A general way to conditionally add or completely remove attributes based on a Component Property would also be useful for disabled, required, readonly, multiple, selected, etc.
Related feature request: Components: Repeater and reusable select property