Skip to content

Conditionally add HTML attributes (e.g. required, disabled) #137

@DannyJJK

Description

@DannyJJK

The Feature Request

There are some HTML attributes that don't have a way to specifiy if the attribute is enabled or disabled, and there are some attributes that don't allow a blank value (e.g. aria-current). Using the disabled attribute as an example, if a button is enabled, it would be:

<button>Test</button>

If a button is disabled, it would be:

<button disabled>Test</button>

Unless I have missed something in the documentation, the only way I can see to do this in SuperHTML is to use <ctx :if="condition"> and write the whole button HTML twice, one for if it's enabled and one for if it's disabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions