ui:useProps
Use props from another component.
This ViewHelper allows you to import all props from another component and register them for the current component.
This is helpful/needed when consuming the primitives components or when you want to reuse props from another component.
You can also override default values of the imported props by passing a defaults array with key-value pairs.
Example
Tooltip/Root.html that uses the tooltip primitive:
<ui:useProps name="primitives:tooltip.root" defaults="{openDelay: 200}" />
<primitives:tooltip.root spreadProps="{true}">
<f:slot />
</primitives:tooltip.root>
Limitation
Currently its not possible to use this useProps and spreadProps pattern with required arguments because of how Fluid parses the templates.
If a prop for a primitive is required, we use the ui:error ViewHelper to manually throw an error if the prop is not set.
Arguments
| Name | Type | Description | Required | Default |
|---|---|---|---|---|
name |
string | Name of component to use the props from | Yes | null |
defaults |
array | Default values for props to override the imported ones. Key-value pairs | No | [] |