Dropdown

Toggle contextual overlays for displaying lists of links and more with the Bootstrap dropdown plugin. Be sure to include popper.min.js before Bootstrap’s JavaScript or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper.

Bootstrap docs: https://getbootstrap.com/docs/5.3/components/dropdowns/

Dropdown

Syntax

$Bootstrap = new renderabootstrap5component();
echo $Bootstrap->dropdown($aButton, $aItems)
Returns: string *

Parameters: 2

Parameter #0 [ <required> array $aButton ] 
array of options for the button. see button() method
 additional flags:
 - split {bool} render caret as small extra button
Parameter #1 [ <required> array $aItems ] 
array of list items in the menu
 - href {string} traget of the link
 - label {string} visible text; a minus "-" creates a divider

Example

PHP snippet

$Bootstrap->dropdown([
  'label' => 'Dropdown button',
  'bgtype' => 'primary',
],
[
  0 => [
    'href' => '#',
    'label' => 'My 1st action',
  ],
  1 => [
    'href' => '#',
    'label' => 'Another action',
  ],
  2 => [
    'label' => '-',
  ],
  3 => [
    'href' => '#',
    'label' => 'A last action',
  ],
]);

Generated html output

<div class="btn-group">
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" type="button">
Dropdown button
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="#">
My 1st action
</a>
</li>
<li>
<a class="dropdown-item" href="#">
Another action
</a>
</li>
<li>
<hr class="dropdown-divider"/>
</li>
<li>
<a class="dropdown-item" href="#">
A last action
</a>
</li>
</ul>

</div>