The \HAPEL\Builder\Details()
class allows for the creation of complete <details>
components.
HAPEL already loads the Details Class automatically so all you need to do is to create an instance of the class like so:
$D = new \lib\builder\Details();
To create an details component, call the details()
method:
echo $D->details($summary, $content, $open, $class, $id, $style, $data, $attr);
Parameter | Type | Required | Default | Use |
---|---|---|---|---|
$summary | string | yes | The contents of the <summary> tag. |
|
$content | string | yes | The contents of the hidden portion. Note: content is unwrapped, allowing you to provide your own wrapper. | |
$open | bool | no | false | True will add the open parameter. |
$class | string, array | no | null | |
$id | string | no | null | |
$style | string, array | no | null | |
$data | array | no | null | |
$attr | array | no | null |
Usage:
$D = new \HAPEL\Builder\Details();
echo $D->details('Click Me', 'I am hidden until clicked.');
Result:
<details>
<summary>Click Me</summary>
I am hidden until clicked.
</details>
Usage:
$D = new \HAPEL\Builder\Details();
echo $D->details('Click Me', 'I am hidden until clicked.', true);
Result:
<details open="open">
<summary>Click Me</summary>
I am hidden until clicked.
</details>
Usage:
$D = new \HAPEL\Builder\Details();
echo $D->details('Click Me', '<p>I am a paragraph.</p><p>So am I.</p>', false, 'my-class');
Result:
<details class="my-class" >
<summary>Click Me</summary>
<p>I am a paragraph.</p><p>So am I.</p>
</details>