dropdown() html()
A dropdown button with a menu of links, headers and dividers; optionally split.
html()->dropdown($items = [], $extra = [])Options
| Option | Meaning |
|---|---|
$items | $link => $text, '-' (divider), ['header' => ...], or ['text', 'link', 'active', 'disabled', 'icon', 'class_add']. |
text, type, size, id | Button text; colour; size; id. |
split, link | A split button whose main part links to link. |
direction, align, dark, auto_close | up / end / start / center; end aligns the menu right; dark menu; Bootstrap 5 auto close. |
Example
Code
$items = [
'#edit' => 'Edit',
'#view' => 'View',
['text' => 'Active item', 'link' => '#active', 'active' => 1],
['text' => 'Disabled', 'link' => '#x', 'disabled' => 1],
'-',
['header' => 'Danger zone'],
['text' => 'Delete', 'link' => '#delete', 'icon' => 'fa fa-trash', 'class_add' => 'text-danger'],
];
return html()->dropdown($items, ['text' => 'Actions'])
. ' ' . html()->dropdown($items, ['text' => 'Split', 'split' => 1, 'link' => '#main', 'type' => 'primary'])
. ' ' . html()->dropdown($items, ['text' => 'Up, right-aligned', 'direction' => 'up', 'align' => 'end']);Notes
- Links are trusted URLs:
javascript:,data:andvbscript:become#; texts are escaped.
Bootstrap 3 and 5
Bootstrap 3: dropup for up and dropdown-menu-right for end; Bootstrap 5 dropdown-menu-end and data-bs-*.
See also: html/button_box, html/navbar, demo:html/bs5_components