composer require php-templates/bootstrap5
or- download project and include
Bootstrap.php
file.
use PhpTemplates\Bootstrap;
$cfg = new Config('default', __DIR__);
$eventHolder = new EventHolder();
$viewFactory = new Template( __DIR__.'/results', $cfg, $eventHolder);
$bs = new Bootstrap;
$bs->mount($viewFactory);
:items
- an associative array holding accordion-item::id => accordion-item::titleclass
- extra classes to.accordion
toggle
- if true/no-value, prevent multiple items to be opened at same timeopen
- true/no-value to render an accordion that’s expanded
-
add each accordion body under a slot with name coresponding to accordion-item::id
will result:
<div class="accordion open " id="accordion-42a87caa5e4606fbccab0def3569c8df">
<div class="accordion-item">
<h2 class="accordion-header" id="ah-lorem">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#ac-lorem" aria-expanded="true" aria-controls="lorem">
Lorem </button>
</h2>
<div id="ac-lorem" class="accordion-collapse collapse show" aria-labelledby="ah-lorem" data-bs-parent="#accordion-42a87caa5e4606fbccab0def3569c8df">
<div class="accordion-body">
<div>
lorem
</div>
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="ah-ipsum">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#ac-ipsum" aria-expanded="false" aria-controls="ipsum">
Ipsum </button>
</h2>
<div id="ac-ipsum" class="accordion-collapse collapse " aria-labelledby="ah-ipsum" data-bs-parent="#accordion-42a87caa5e4606fbccab0def3569c8df">
<div class="accordion-body">
<div>
ipsum
</div>
</div>
</div>
</div>
</div>
type
- bs5 theme colors (primary, secondary, etc)title
- alert h4 title (optional)dismiss
- display dismiss buttonicon
- hide alert icon if false
-
default
- alert message -
title
- title override, if a complex one is needed -
icon
- slot for icon
Aww yeah, you successfully read this important alert message
```will result:
<div class="alert alert-success alert-dismissible fade show" role="alert">
<div class="d-flex">
<div class="d-flex align-items-center pe-1">
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="currentColor" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
</svg>
</div>
<div class="flex-fill">
<h4 class="alert-heading">Well done</h4>
<p class="m-0">Aww yeah, you successfully read this important alert message</p>
</div>
</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
v
- bs theme colorsclass
- extra classes
-
default
- text value of the badge
12
will result:
-
:items
- an array holding items of form['label'=>'Displayed', 'value'=>'href']
-
class
- extra classes
will result:
<nav aria-label="breadcrumb" class="">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Product</li>
</ol>
</nav>
-
v
- variant - primary, secondary, etc -
class
- extra classes -
href
- if given, it will render an anchor instead of button -
size
- sm, lg (btn-*) -
disabled
- true/no value = disabled
OK OK
will result:
header
- card header textfooter
- card footer textimg
- card image srcalt
- card image altclass
- custom img class
-
default
- .card-body content -
header
- .card-header content -
above
- above .card-body -
below
- below .card-body -
footer
- .card-footer content
will result:
<div class="card">
<div class="card-header">
Lorem </div>
<div class="card-body">
Sit amen
</div>
<div class="card-footer">
Ipsum </div>
</div>
type
- dropdown(default), dropup, dropstart, dropendv
- primary, secondary, etcsize
- sm, md, lg, etcid
- button idlabel
- button textul_class
- list class:items
- an array of items where item like ['type' => 'title,text,separator or item', 'text' => 'item text', 'href' => $optional, 'disabled' => $optional, 'active' => $optional, '_attrs' => $optionalItemBinds]
-
default
- the dropdown content if custom content required -
btn-inner
- button childnode
will result:
title
- modal titlefade
- if false, no fade effect appliedsize
- sm, md, lg, etcid
- modal idclass
- modal classesc
- if should close on esc keypressscrollable
- if modal is scrollablecentered
- if modal should be vertically centered
-
default
- modal body -
header
- .modal-header childNodes -
footer
- .modal-footer childNodes
will result:
<div class="modal fade" id="mymodal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="mymodal" aria-hidden="true">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
Demo modal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
modal body
</div>
<div class="modal-footer">
<button class="btn btn-primary ">
Btn
</button>
</div>
</div>
</div>
</div>
-
:items
- an array holding items of form['label'=>'Displayed', 'value'=>'href', 'disabled'=>$optional, 'active'=>$optional]
-
class
- extra classes
will result:
- Lorem
- ipsum
:items
- associative array holding $tab_id => $labelvalue
- selected tab by idvertical
- if you want tabs to be verticalclass
- extra .nav-tabs classesid
- .nav-tabs idfade
- if false, no fade effect
-
one slot for each $tab_id may be passed
will result:
<div >
<ul class="nav nav-tabs" id="t-638a8a56c3361" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link " id="lorem-tab" data-bs-toggle="tab" data-bs-target="#lorem" type="button" role="tab" aria-controls="lorem" aria-selected="true">Lorem</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link active" id="ipsum-tab" data-bs-toggle="tab" data-bs-target="#ipsum" type="button" role="tab" aria-controls="ipsum" aria-selected="true">Ipsum</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade" id="lorem" role="tabpanel" aria-labelledby="lorem-tab">
<div>lorem</div>
</div>
<div class="tab-pane fade show active" id="ipsum" role="tabpanel" aria-labelledby="ipsum-tab">
<div>ipsum</div>
</div>
</div>
</div>
pos
- .offcanvas position, default topclass
- .offcanvas extra classesid
- .offcanvas idscroll
- body scroll allowed or notbackdrop
- .offcanvas backdrop
-
default - offcanvas body child nodes
Toggle top offcanvas
... ```will result:
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasTop" aria-controls="offcanvasTop">Toggle top offcanvas</button>
<div class="offcanvas offcanvas-top" tabindex="-1" id="offcanvasTop" data-bs-scroll="false" data-bs-backdrop="false" aria-labelledby="offcanvasTopLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasTopLabel">Lorem Ipsum</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
...
</div>
</div>
Create form-group structures in a single line using b-form-group
tag. You can create input groups, prepends, appends, inline forms and column forms of any type.
type
- text, textarea, checkbox, select, switch, etc...class
- form-group extra classsize
- form-control sizeoptions
- when type = select, an array of [label=>text,value=>value] structuresprepend
- prepend textappend
- append text- p-bind is present on form-control to pass forward any extra attribute
- prepend - prepend custom, if more then a text is needed
- append - append custom, if more then a text needed