Skip to content

Latest commit

 

History

History
90 lines (67 loc) · 3.14 KB

details.md

File metadata and controls

90 lines (67 loc) · 3.14 KB

HAPEL Builder Reference


Details

Description

The \HAPEL\Builder\Details() class allows for the creation of complete <details> components.


Getting Started

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();

Creating Details Components

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

Examples

Basic Usage

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>

Start Details Open

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>

Setting Additional Parameters

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>