Skip to main content

$childrens

The $childrens special helper allows a component to access the elements passed inside its tag. This is useful for handling slots or dynamically rendering child elements within a component.

Syntax

<ErrorMessage>
<p>Hello</p>
</ErrorMessage>

Inside ErrorMessage:

console.log($childrens); // [<p>Hello</p>]

Example

<component>
<p>This element is injected in the component.</p>
</component>
const Component = DOMY.createComponent({
html: `<template d-insert="$childrens[0]"></template>`
});