Skip to main content

ui:attributes

Renders arbitrary HTML attributes.

When this ViewHelper is used inside a component, all attributes that are not defined as props will be collected and made available via this ViewHelper.

Examples

Usage on HTML elements

<ui:button class="my-button" data-test="123" disabled />

Inside the button component, you can use this ViewHelper to render the attributes:

<button {ui:attributes()}></button>

This will render:

<button class="my-button" data-test="123" disabled></button>

Usage on other components

When you need to pass the attributes to another component, you can use its attributes prop. This prop is automatically added to components that use the ui:attributes ViewHelper inside them.

<ui:someComponent attributes="{ui:attributes()}" />

Arguments

Name Type Description Required Default
skip string A comma-separated list of attributes to skip No null
only string A comma-separated list of attributes to include. All other attributes will be skipped No null
asArray boolean If true, the attributes will be rendered as an array instead of a string. Useful when you need to pass the attributes to a Tag-ViewHelper with the additionalAttributes argument No false