Create Bootstrap grids, tables, forms, buttons, dropdowns, groups, navs, breadcrumbs, pagination, panels, accordions, carousels, etc ... all without touching a single div!
The Bootstrap Component allows you to easily generate Bootstrap tables, navs, pagination, buttons, dropdowns, accordions, carousels ... you name it - all without touching a single div! Of course, if you like spelling it all out then there is really no need for this class. It is simply here to help make your HTML more readable, easy to update, and less buggy.
A BootPress\Bootstrap\Table instance that extends the BootPress Table Component with the following method:
Create a <table>
.
<table>
attributes. Any 'responsive', 'bordered', 'striped', 'hover', and/or 'condensed' class will be prefixed with a 'table-...', and include the 'table' class as well.
Table <caption>
.
echo $bp->table->open('class=responsive striped');
echo $bp->table->head();
echo $bp->table->cell('', 'One');
echo $bp->table->row();
echo $bp->table->cell('', 'Two');
echo $bp->table->foot();
echo $bp->table->cell('', 'Three');
echo $bp->table->close();
This method works in conjunction with $bp->col()
below. It makes things a little less verbose, but much easier to edit, modify, and see at a glance what in the world is going on.
This value can be either 'xs' < 768px, 'sm' >= 768px, 'md' >= 992 , or 'lg' >= 1200. This is the point at which your grid will break, if no smaller size is indicated. With this method you can indicate multiple sizes by simply inserting another argument. All of your $size
's must correspond with the values given in the $bp->col()
's or $columns
below.
An array of $bp->col()
's. This argument does not need to be the second one in line. It is merely the last one given.
echo $bp->row('sm', array(
$bp->col(3, 'left'),
$bp->col(6, 'center'),
$bp->col(3, 'right'),
));
This is a helper method for $bp->row()
above. It only returns it's own arguments, but it helps to keep things straight. Including arrays within arrays can get to be a little unwieldly, just take a look at the $bp->media()
method.
This parameter must correspond with it's parent $bp->row($size)
. It can be an integer between 1 and 12, as long as all of the $bp->col()
's respective numbers add up to 12 or less. To get fancy you can add a space, then an 'offset-', 'push-', or 'pull-' followed by the number of columns that you would like to affect. All of these will be preceded by col-{$size}-...
. To include additional classes just keep on going with a space in between each.
The actual html content you would like to be placed in this column.
The parameters passed to it.
echo $bp->row('sm', 'md', 'lg', array(
$bp->col(12, '9 push-3', '10 push-2', 'content'),
$bp->col('6 offset-3 clearfix', '3 pull-9', '2 pull-10', 'sidebar'),
));
This assists you in making Ordered, Unordered, and Definition lists. It is especially useful when you are nesting lists within lists. Your code almost looks exactly like you would expect to see it on the big screen. It would have been nice if we could have named this method 'list', but someone has taken that already.
Either an 'ol' (Ordered list), 'ul' (Unordered list), or a 'dl' (Definition list). You can add any other classes you like (or not), but the special ones that Bootstrap has blessed us with are:
For Ordered and Unordered lists this is an array($li, $li, ...)
, and to nest another list just make the $li
another array.
For Definition Lists this is an array($title => $definition, ...)
. If you have multiple $definition
's, then just make $title
an array of them.
echo $bp->lister('ol', array(
'Coffee',
'Tea' => array(
'Black tea',
'Green tea',
),
'Milk',
));
echo $bp->lister('ul list-inline', array(
'Coffee',
'Tea',
'Milk',
));
echo $bp->lister('dl dl-horizontal', array(
'Coffee' => array(
'Black hot drink',
'Caffeinated beverage',
),
'Milk' => 'White cold drink',
));
This will assist you in creating a search bar for your site.
This is the url that you would like the search term to be sent to
To customize the form, you can submit an array with any of the following keys:
$bp->icon('search')
.
<form>
tag. The default is 'form-horizontal'.echo $bp->search('http://example.com');
Create a Bootstrapped good looking form.
The name of your form.
How you would like the form to be sent ie. 'post' or 'get'.
A BootPress\Bootstrap\Form instance that extends the BootPress Form Component with the following methods:
Display a message to your user after $form->eject()
ing them. The Bootstrap alert status message will be displayed at the top of the form when you return $form->header()
.
Either 'success', 'info', 'warning', or 'danger'. If this is 'html', then the $message will be delivered as is.
The message you would like to get across to your user. <h1-6>
headers and <a>
links will be appropriately classed.
if ($vars = $form->validator->certified()) {
$form->message('info', 'Good job, you are doing great!');
$form->eject();
}
Supersize or undersize your input fields.
Either 'lg' (large), 'md' (medium - the default), or 'sm' (small).
$form->size('lg');
Utilize any Bootstrap form style.
The options are:
Either 'xs', 'sm', 'md', or 'lg'. This is the breaking point so to speak for a 'horizontal' form. It is the device size on which the form will 'collapse'.
The number of columns (up to 12) that you would like to indent the field in a 'horizontal' form.
$form->align('collapse');
This is to add html tags, or semicolons, or asterisks, or whatever you would like to all of the form's prompts.
Either 'info', 'append', or 'prepend' to the prompt. You only have one shot at each.
Whatever you would like to add. For 'info', this will be the icon class you want to use.
If $place == 'prepend'
and this is anything but (bool) false, then the $html will only be prepended if the $form->validator->required('field')
.
$form->prompt('prepend', '<font color="red">*</font> ', 'required'); // If the field is required it will add a red asterisk to the front.
$form->prompt('append', ':'); // Adds a semicolon to all of the prompts.
Creates the <form>
, invokes the Validator jQuery, and displays your message (if any).
Override the custom validator settings we have created for Bootstrap
echo $form->header();
Creates checkboxes from the $form->menu($field)
you set earlier.
The checkbox's name.
Anything else you would like to add besides the 'name', 'value', 'checked', and data validation attributes.
This tells us if you want the checkboxes to be inline (any value but false), or not (false).
A checkbox <label><input type="checkbox" ...></label>
html tag.
$form->menu('remember', array('Y'=>'Remember Me'));
$form->validator->set('remember', 'yesNo');
echo $form->checkbox('remember');
Creates radio buttons from the $form->menu($field)
you set earlier.
The radio button's name.
Anything else you would like to add besides the 'name', 'value', 'checked', and data validation attributes.
This tells us if you want the radio buttons to be inline (any value but false), or not (false).
Radio <label><input type="radio" ...></label>
html tags.
$form->menu('gender', array('M'=>'Male', 'F'=>'Female'));
$form->validator->set('gender', 'required|inList');
echo $form->radio('gender');
Group an input field with addons. You can prepend and/or append a $bp->button(...)
, $bp->icon(...)
, or just a string of text. To prepend or append multiple elements, then make it an array($html, ...)
of addons.
An element to place before the $input.
An element to place after the $input.
The form field to wrap.
A <div class="input-group">...</div>
html string.
echo $form->group('$', '.00', $form->text('amount'));
Adds a (properly formatted) $prompt to your $input field, and manages any error messages.
For the $input field. If you want to include additional info that will appear when clicked or hovered over, then you can make this an array($prompt => $info)
. To customize the icon used, set $form->prompt('info', 'fa fa-info-circle')
.
A form field, or help block, etc.
An optional error to override, and include with the field.
A <div class="form-group">...</div>
html string.
echo $form->field('Amount', $form->group('$', '.00', $form->text('amount')));
Quickly adds a submit button to your form.
What you would like the submit button to say. If it starts with a '<', then we assume you have spelled it all out for us.
This will add a reset button if you give it a value, and if it starts with a '<' then it can be whatever you want it to be. You can keep adding args until you run out of ideas for buttons to include.
A <div class="form-group">...</div>
html string with buttons.
echo $form->submit();
$form = $bp->form('sign_in');
$form->menu('remember', array('Y' => 'Remember me'));
$form->validator->set(array(
'email' => 'required|email',
'password' => 'required|minLength[5]|noWhiteSpace',
'remember' => 'yesNo',
));
if ($vars = $form->validator->certified()) {
$form->message('info', 'Good job, you are doing great!');
$form->eject();
}
$form->size('lg'); // oversize the inputs
$form->align('collapse'); // default is horizontal
echo $form->header();
echo $form->fieldset('Sign In', array(
$form->field('Email address', $form->group($bp->icon('user'), '', $form->text('email'))),
$form->field('Password', $form->group($bp->icon('lock'), '', $form->password('password'))),
$form->field('', $form->checkbox('remember'),
$form->submit(),
));
echo $form->close();
A BootPress\Bootstrap\Navbar instance with the following methods:
Create a new navbar.
The name of your website. If this is a string then it will automatically link to your $page->url['base']
. If you want to override that, then make this an array($brand => $link)
.
Either 'top', 'bottom', or 'static' if you want to fix the alignment. If you're just trying to get to the next arg then you can declare 'inverse' here, and we'll know what you're talking about.
If this is anything but false (eg. 'inverse'), then we will display the inverted or alternate navbar.
echo $bp->navbar->open(array('Website' => 'http://example.com'));
Create a menu of links across your navbar.
An array($name => $href, ...)
of links. If $href
is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with buttons.
The options available here are:
echo $bp->navbar->menu(array(
'Home' => '#',
'Work' => '#',
'Dropdown' => array(
'Action' => '#',
'More' => '#',
),
), array(
'active' => 'Home',
));
Exactly the same as $bp->button()
, except that it will receive a 'navbar-btn' class.
To pull it one way or the other, you can add the class 'navbar-right or 'navbar-left'.
The text of your button.
You can also pull the button here by adding array('pull' => 'right')
or array('pull' => 'left')
.
echo $bp->navbar->button('primary', 'Sign In', array(
'pull' => 'right',
));
Exactly the same as $bp->search()
, except the <form>
will receive a 'navbar-form navbar-right' class.
Where to send the search term.
You can pull the search form left by adding array('class' => 'navbar-form navbar-left')
.
echo $bp->navbar->search('http://example.com', array(
'button' => false,
));
Add a string of text to your navbar.
The message you would like to get across. It will be wrapped in a <p class="navbar-text">
tag, and any <a>
's will be classed with a 'navbar-link'.
Either 'left' or 'right'.
echo $bp->navbar->text('You <a href="#">link</a> me');
Add the final </div>
's and </nav>
.
echo $bp->navbar->close();
A BootPress\Bootstrap\Pagination instance that extends the BootPress Pagination Component with the 'bootstrap' defaults.
Create an icon without the verbosity.
The icon you would like to display without the base and icon class prefix.
The base and icon class prefix. The default is a Bootstrap icon, but this can be used with any icon font by simply entering their prefix value here.
The tag to use for displaying your font. Everyone uses the <i>
tag, so that is the default. If $prefix == 'glyphicon'
(the default for Bootstrap) then we will use a span element. Why? I don't know, but since v.2 that seems to be what they prefer to use now. If you want to style an icon further then you can do so here. eg. 'i style="font-size:16px;"'
.
echo $bp->icon('asterisk');
A button by itself is easy enough, but when you start including dropdowns and groups your markup can get ugly quick. Follow the examples. We'll start simple and go from there.
The classes: 'xs', 'sm', 'lg', 'block', 'default', 'primary', 'success', 'info', 'warning', 'danger', and 'link' will all be prefixed with 'btn-...', and we include the 'btn' class too. Notice how we left out the 'btn-group' option? Don't worry about that one. Feel free to add any more that you like such as 'disabled'.
The text of your button. You may also include badges, labels, icons, etc, but leave the caret up to us. If you are including a dropdown menu and you would like to split the button from the menu, then you can make this an array('split' => $name)
.
These are all of the attributes that you would like to include in the <button>
tag, except if you include an 'href' key then it will be an <a>
tag. Other potential options include: 'id', 'style', 'title', 'type', 'data-...', etc, but the ones we take notice of and do special things with are:
array($name => $link, ...)
of names and their associated links.
echo $bp->button('primary', 'Primary');
echo $bp->button('lg success', 'Link', array('href'=>'#'));
echo $bp->button('default', 'Dropdown', array(
'dropdown' => array(
'Header',
'Action' => '#',
'Another action' => '#',
'Active link' => '#',
'',
'Separated link' => '#',
'Disabled link' => '#',
),
'active' => 'Active link',
'disabled' => 'Disabled link',
));
Group your buttons together.
The classes: 'xs', 'sm', 'lg', 'justified', and 'vertical' will all be prefixed with 'btn-group-...', and we include the 'btn-group' class too. When you size a group up, then don't size the individual buttons.
An array($bp->button(), ...)
of buttons.
This can be either 'checkbox' or 'radio' and your button group will act accordingly.
echo $bp->group('', array(
$bp->button('default', 'Left'),
$bp->button('default', 'Middle'),
$bp->button('default', array('split'=>'Right'), array(
'dropdown' => array(
'Works' => '#',
'Here' => '#',
'Too' => '#',
),
'pull' => 'right',
)),
));
This used to be a private method that we only used internally for tabs and pills and buttons and so forth, but it is just so useful. Now you can make your own dropdowns with regular <a>
links as well.
If this isn't 'li', then it will be an 'a'. If you specify 'li' tags then you will need to surround this method's output with your own <ul>
or <ol>
tags. Otherwise you can just use the returned <a>
$links (with dropdowns if any) as is. The <a>
's with dropdowns will be surrounded by a <span class="dropdown">
. If one of those dropdown links are active then the <span>
and <a>
tags will receive an additional 'active' class as well. To add any other class(es) to the <a>
or <li>
tags just add them after the $tag here eg. 'a special-class'.
An array($name => $href, ...)
of links. If $href is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with $bp->buttons()
.
The available options are:
echo $bp->links('a special-class', array(
'Home' => BASE_URL,
'Dropdown' => array(
'Header',
'Action' => '#',
'Another Action' => '#',
),
), array(
'active' => 'url',
));
Creates a Bootstrap tabs nav menu.
An array($name => $href, ...)
of links. If $href is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with $bp->buttons()
.
The available options are:
echo $bp->tabs(array(
'Nav' => '#',
'Tabs' => '#',
'Justified' => '#',
), array(
'align' => 'justified',
'active' => 1,
));
Creates a Bootstrap pills nav menu.
An array($name => $href, ...)
of links. If $href is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with $bp->buttons()
.
The available options are:
echo $bp->pills(array(
'Home ' . $bp->badge(42) => '#',
'Profile' . $bp->badge(0) => '#',
'Messages' . $bp->badge(3) => array(
'New! ' . $bp->badge(1) => '#',
'Read ' => '#',
'Trashed ' => '#',
'',
'Spam ' . $bp->badge(2) => '#',
),
), array(
'active' => 'Home',
));
Creates a Bootstrap styled breadcrumb trail. The last link is automatically activated.
An array($name => $href)
of links to display. The $href may also be another array($name => $href)
of dropdown links.
$bp->breadcrumbs(array(
'Home' => '#',
'Library' => '#',
'Data' => '#',
));
Creates a Bootstrap label, and saves you from having to type the label twice. Awesome, right?
Either 'default', 'primary', 'success', 'info', 'warning', or 'danger'. The 'label' class and prefix are automatically included. You can add more classes to it if you like.
The label's text.
echo $bp->label('default', 'New');
Creates a Bootstrap badge, and is a bit more useful than $bp->label()
. If $count equals 0, or if it's not numeric (null?), then it still includes the tag, but leaves the value empty.
The number you would like to display.
This will pull your badge 'right' or 'left' or not (default). In a list group, badges are automatically positioned to the right.
echo $bp->badge(13, 'right');
Creates Bootstrap alert messages.
Either 'success', 'info', 'warning', or 'danger'.
The status message. All <h1-6>
headers and <a>
links will be classed appropriately.
If you set this to false, then the alert will not be dismissable.
echo $bp->alert('info', '<h3>Heads up!</h3> This alert needs your attention, but it\'s not <a href="#">super important</a>.');
echo $bp->alert('danger', '<h3>Oh snap!</h3> Change a few things up and <a href="#">try submitting again</a>.', false);
Creates every flavor of progress bar that Bootstrap has to offer.
The amount of progress from 0 to 100. In order to stack multiple values then turn this into an array.
You can include one of the four contextual classes: 'success', 'info', 'warning' or 'danger'. Also 'striped' and 'active' if you like the looks of those. These will all be properly prefixed with 'progress-...'. If you are stacking multiple bars, then turn this into an array and make sure your classes correspond with your percentages.
If anything but false, then the percentage will be displayed in the progress bar.
echo $bp->progress(60, 'info', 'display');
echo $bp->progress(array(25, 25, 25, 25), array('', 'warning', 'success', 'danger striped'));
This is the easiest way I could devise of making Bootstrap media objects as manageable as possible. <h1-6>
headers and <img>
es will automatically be classed appropriately.
A media array row that looks like this: array($left, $body, $right)
.
array('id' => $id, 'class' => 'custom', $left, $body, $right);
$bp->media(array($left, $body, $right), array($left, $body, $right), array($left, $body, $right));
array($left, $body, $right, array($left, $body, $right, array($left, $body, $right)));
- This would be a parent, child, grandchild arrangement.array($left, $body, $right, array($left, $body, $right), array($left, $body, $right));
- A parent, child, child condition.array($left, $body, $right, array($left, $body, $right, array($left, $body, $right), array($left, $body, $right)), array($left, $body, $right)), array($left, $body, $right));
- Now I'm just messing with you, but I think you've got the picture (a parent, child, grandchild, grandchild, child, sibling).echo $bp->media(array(
'Image',
'<h1>Parent</h1> <p>Paragraph</p>',
'<img src="parent.jpg" alt="Family Photo">',
array(
'Image',
'<h2>1st Child</h2>',
array(
'Image',
'<h3>1st Grandchild</h3>',
),
),
array(
'Image',
'<h2>2nd Child</h2>',
),
), array(
'class' => 'special',
'Image',
'<h1>Sibling</h1> <a href="#">Link</a>',
'<img src="sibling.jpg" alt="Family Photo">',
));
Creates a Bootstrap list group. <h1-6>
Headers and <p>
paragraphs will automatically be classed appropriately.
If you would like to create an unordered list, then this is just an array of values. Otherwise this will be an array($name => $href, ...)
of links. $name badges will automatically be positioned on the right.
This value can be either the $name, $href (link), or an integer (starting from 1) that you would like to be selected as "active".
$bp->listGroup(array(
'Basic',
'List',
$bp->badge(1) . ' Group',
));
$bp->listGroup(array(
'Linked' => '#',
'List' => '#',
'Group ' . $bp->badge(2) => '#',
), 'Linked');
$bp->listGroup(array(
'<h4>Custom</h4> <p>List</p>' => '#',
$bp->badge(3) . ' <h4>Group</h4> <p>Linked</p>' => '#',
), 1);
Creates a Bootstrap panel component.
Either 'default', 'primary', 'success', 'info', 'warning', or 'danger'. The 'panel' class and prefix are automatically included. You can add more classes to it if you like.
An array($panel => $content, ...)
of sections. If $panel equals:
<h1-6>
headers will be classed appropriately.echo $bp->panel('primary', array(
'header' => '<h3>Title</h3>',
'body' => 'Content',
'footer' => '<a href="#">Link</a>',
));
echo $bp->panel('default', array(
'header': 'List group',
$bp->listGroup(array(
'One',
'Two',
'Three',
)),
));
Creates toggleable tabs and pills for transitioning through panes of local content.
Specify either 'tabs' or 'pills'.
An array($name => $html, ...)
of content to toggle through. If $html is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with $bp->buttons()
.
The available options are:
echo $bp->toggle('tabs', array(
'Home' => 'One',
'Profile' => 'Two',
'Dropdown' => array(
'This' => 'Three',
'That' => 'Four',
),
), array(
'active' => 'This',
'fade',
));
Bootstrap accordions are basically collapsible panels. That is essentially what you are creating here.
Either 'default', 'primary', 'success', 'info', 'warning', or 'danger'. These only apply to the head section, and are passed directly by us into $bp->panel()
.
An array($heading => $body, ...)
of sections that will become your accordion. The <h1-6>
headers in the $heading will be automatically classed appropriately. Accordions are definitely nestable, but we don't create them via nested arrays through this method. Just add a pre-made accordion to the $body you would like it to reside in ie. the $body should never be an array.
This is the panel number you would like be open from the get-go (starting at 1). If you don't want any panel to be opened initially, then set this to 0.
echo $bp->accordion('info', array(
'<h4>Group Item #1</h4>' => 'One',
'<h4>Group Item #2</h4>' => 'Two',
'<h4>Group Item #3</h4>' => 'Three',
), 2);
Creates a Bootstrap carousel for cycling through elements. Those elements don't necessarily need to be images, but pretty much they always are.
An array($image, ...)
of images to cycle through, starting with the first (logically). To get fancy and add captions, then make this an array($image => $caption, ...)
of images with captions to cycle through. If you have some images with captions and others without, then you can merge these two concepts no problem. Remember, the $image is not just a location, it is the entire <img>
tag src and all.
The available options are:
array($bp->icon('chevron-left'), $bp->icon('chevron-right'))
for the left and right arrows. If you would like something else, then you can make this an array of your preferences.echo '<div style="width:500px; height:300px; margin:20px auto;">';
echo $bp->carousel(array(
'<img src="http://lorempixel.com/500/300/food/1/" width="500" height="300">',
'<img src="http://lorempixel.com/500/300/food/2/" width="500" height="300">' => '<p>Caption</p>',
'<img src="http://lorempixel.com/500/300/food/3/" width="500" height="300">' => '<h3>Header</h3>',
), array(
'interval' => 3000,
));
echo '</div>';
Add the following to your composer.json
file.
{
"require": {
"bootpress/bootstrap": "^1.0"
}
}
<?php
use BootPress\Bootstrap\v3\Component as Bootstrap;
// To use in your BootPress Blog's Twig templates:
$blog = new \BootPress\Blog\Component();
$blog->theme->vars['bp'] = new Bootstrap();
The Twig Template examples will output the Bootstrap HTML.
Twig Template
{{ bp.row('sm', [
bp.col(3, 'left'),
bp.col(6, 'center'),
bp.col(3, 'right'),
]) }}
{{ bp.row('sm', 'md', 'lg', [
bp.col(12, '9 push-3', '10 push-2', 'content'),
bp.col('6 offset-3 clearfix', '3 pull-9', '2 pull-10', 'sidebar'),
]) }}
Bootstrap HTML
<div class="row">
<div class="col-sm-3">left</div>
<div class="col-sm-6">center</div>
<div class="col-sm-3">right</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-9 col-md-push-3 col-lg-10 col-lg-push-2">content</div>
<div class="col-sm-6 col-sm-offset-3 clearfix col-md-3 col-md-pull-9 col-lg-2 col-lg-pull-10">sidebar</div>
</div>
Twig Template
{{ bp.lister('ol', [
'Coffee',
'Tea': [
'Black tea',
'Green tea',
],
'Milk',
]) }}
{{ bp.lister('ul list-inline', [
'Coffee',
'Tea',
'Milk',
]) }}
{{ bp.lister('dl dl-horizontal', [
'Coffee': [
'Black hot drink',
'Caffeinated beverage',
],
'Milk': 'White cold drink',
]) }}
Bootstrap HTML
<ol>
<li>Coffee</li>
<li>Tea
<ol>
<li>Black tea</li>
<li>Green tea</li>
</ol>
</li>
<li>Milk</li>
</ol>
<ul class="list-inline">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<dl class="dl-horizontal">
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dd>Caffeinated beverage</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
Twig Template
{{ bp.table.open('class=responsive striped') }}
{{ bp.table.head() }}
{{ bp.table.cell('', 'One') }}
{{ bp.table.row() }}
{{ bp.table.cell('', 'Two') }}
{{ bp.table.foot() }}
{{ bp.table.cell('', 'Three') }}
{{ bp.table.close() }}
Bootstrap HTML
<table class="table table-responsive table-striped">
<thead>
<tr>
<th>One</th>
</tr>
</thead>
<tbody>
<tr>
<td>Two</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Three</td>
</tr>
</tfoot>
</table>
Twig Template
{% set form = bp.form('sign_in') %}
{{ form.menu('remember', ['Y':'Remember me']) }}
{{ form.validator.set([
'email': 'required|email',
'password': 'required|minLength[5]|noWhiteSpace',
'remember': 'yesNo',
]) }}
{% set vars = form.validator.certified() %}
{% if vars %}
{{ form.message('info', 'Good job, you are doing great!') }}
{{ form.eject() }}
{% endif %}
{{ form.size('lg') }}
{{ form.align('collapse') }}
{{ form.header() }}
{{ form.fieldset('Sign In', [
form.field('Email address', form.group(bp.icon('user'), '', form.text('email'))),
form.field('Password', form.group(bp.icon('lock'), '', form.password('password'))),
form.field('', form.checkbox('remember')),
form.submit(),
]) }}
{{ form.close() }}
Bootstrap HTML
<form name="sign_in" method="post" action="http://example.com?submitted=sign_in" accept-charset="utf-8" autocomplete="off">
<fieldset><legend>Sign In</legend>
<div class="form-group">
<label class="input-lg" for="emailI">Email address</label>
<p class="validation help-block" style="display:none;"></p>
<div class="input-group input-group-lg">
<div class="input-group-addon">
<span class="glyphicon glyphicon-user"></span>
</div>
<input type="text" name="email" id="emailI" data-rule-required="true" data-rule-email="true" class="form-control input-lg">
</div>
</div>
<div class="form-group">
<label class="input-lg" for="passwordII">Password</label>
<p class="validation help-block" style="display:none;"></p>
<div class="input-group input-group-lg">
<div class="input-group-addon">
<span class="glyphicon glyphicon-lock"></span>
</div>
<input type="password" name="password" id="passwordII" data-rule-required="true" data-rule-minlength="5" data-rule-nowhitespace="true" class="form-control input-lg">
</div>
</div>
<div class="form-group">
<p class="validation help-block" style="display:none;"></p>
<div class="checkbox input-lg">
<label><input type="checkbox" name="remember" value="Y"> Remember me</label>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-lg" data-loading-text="Submitting...">Submit</button>
</div>
</fieldset>
</form>
Twig Template
{{ bp.button('primary', 'Primary') }}
{{ bp.button('lg success', 'Link', ['href':'#']) }}
{{ bp.button('link', 'Button') }}
Bootstrap HTML
<button type="button" class="btn btn-primary">Primary</button>
<a href="#" class="btn btn-lg btn-success">Link</a>
<button type="button" class="btn btn-link">Button</button>
Twig Template
{{ bp.button('default', 'Dropdown', [
'dropdown': [
'Header',
'Action': '#',
'Another action': '#',
'Active link': '#',
'',
'Separated link': '#',
'Disabled link': '#',
],
'active': 'Active link',
'disabled': 'Disabled link',
]) }}
Bootstrap HTML
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" id="dropdownI" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></button>
<ul class="dropdown-menu" aria-labelledby="dropdownI">
<li role="presentation" class="dropdown-header">Header</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
<li role="presentation" class="active"><a role="menuitem" tabindex="-1" href="#">Active link</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
<li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Disabled link</a></li>
</ul>
</div>
Twig Template
{{ bp.group('', [
bp.button('default', 'Left'),
bp.button('default', 'Middle'),
bp.button('default', ['split':'Right'], [
'dropdown': [
'Works': '#',
'Here': '#',
'Too': '#',
],
'pull': 'right',
]),
]) }}
Bootstrap HTML
<div class="btn-group" role="group">
<button type="button" class="btn btn-default">Left</button>
<button type="button" class="btn btn-default">Middle</button>
<div class="btn-group">
<button type="button" class="btn btn-default">Right</button>
<button type="button" class="btn btn-default dropdown-toggle" id="dropdownI" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span> <span class="sr-only">Toggle Dropdown</span></button>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownI">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Works</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Here</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Too</a></li>
</ul>
</div>
</div>
Twig Template
{{ bp.tabs([
'Nav': '#',
'Tabs': '#',
'Justified': '#',
], [
'align': 'justified',
'active': 1,
]) }}
Bootstrap HTML
<ul class="nav nav-tabs nav-justified">
<li role="presentation" class="active"><a href="#">Nav</a></li>
<li role="presentation"><a href="#">Tabs</a></li>
<li role="presentation"><a href="#">Justified</a></li>
</ul>
Twig Template
{{ bp.pills([
'Home ' ~ bp.badge(42): '#',
'Profile ' ~ bp.badge(0): '#',
'Messages ' ~ bp.badge(3): [
'New! ' ~ bp.badge(1): '#',
'Read ': '#',
'Trashed ': '#',
'',
'Spam ' ~ bp.badge(2): '#',
],
], [
'active': 'Home',
]) }}
Bootstrap HTML
<ul class="nav nav-pills">
<li role="presentation" class="active"><a href="#">Home <span class="badge">42</span></a></li>
<li role="presentation"><a href="#">Profile <span class="badge"></span></a></li>
<li class="dropdown"><a id="dropdownI" data-target="#" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Messages <span class="badge">3</span> <span class="caret"></span></a>
<ul class="dropdown-menu" aria-labelledby="dropdownI">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">New! <span class="badge">1</span></a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Read </a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Trashed </a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Spam <span class="badge">2</span></a></li>
</ul>
</li>
</ul>
Twig Template
{{ bp.navbar.open(['Website':'http://example.com']) }}
{{ bp.navbar.menu([
'Home': '#',
'Work': '#',
'Dropdown': [
'Action': '#',
'More': '#',
],
], [
'active': 'Home',
]) }}
{{ bp.navbar.button('primary', 'Sign In', [
'pull': 'right',
]) }}
{{ bp.navbar.search('http://example.com', [
'button': false,
]) }}
{{ bp.navbar.close() }}
Bootstrap HTML
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbarI">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://example.com">Website</a>
</div>
<div class="collapse navbar-collapse" id="navbarI">
<ul class="nav navbar-nav">
<li role="presentation" class="active"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Work</a></li>
<li class="dropdown">
<a id="dropdownII" data-target="#" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" aria-labelledby="dropdownII">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">More</a></li>
</ul>
</li>
</ul>
<button type="button" class="btn btn-primary navbar-btn navbar-right">Sign In</button>
<form name="search" method="get" action="http://example.com" accept-charset="utf-8" autocomplete="off" role="search" class="navbar-form navbar-right">
<input type="text" class="form-control" placeholder="Search" name="search" id="searchIII" data-rule-required="true">
</form>
</div>
</div>
</nav>
Twig Template
{{ bp.breadcrumbs([
'Home': '#',
'Library': '#',
'Data': '#',
]) }}
Bootstrap HTML
<ul class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Library</a></li>
<li class="active">Data</li>
</ul>
Twig Template
{% set records = range(1, 100) %}
{% if not bp.pagination.set('page', '10', 'http://example.com') %}
{{ bp.pagination.total(records|length) }}
{% endif %}
{{ bp.pagination.links() }}
{{ bp.pagination.pager() }}
Bootstrap HTML
<ul class="pagination">
<li class="active"><span>1</span></li>
<li><a href="http://example.com?page=2of10">2</a></li>
<li><a href="http://example.com?page=3of10">3</a></li>
<li><a href="http://example.com?page=4of10">4</a></li>
<li><a href="http://example.com?page=5of10">5</a></li>
<li><a href="http://example.com?page=6of10">6</a></li>
<li><a href="http://example.com?page=7of10">7</a></li>
<li class="disabled"><span>…</span></li>
<li><a href="http://example.com?page=10of10">10</a></li>
<li><a href="http://example.com?page=2of10">»</a></li>
</ul>
<ul class="pager">
<li class="next"><a href="http://example.com?page=2of10">Next »</a></li>
</ul>
Twig Template
{{ bp.label('default', 'New') }}
Bootstrap HTML
<span class="label label-default">New</span>
Twig Template
{{ bp.badge(13, 'right') }}
Bootstrap HTML
<span class="badge pull-right">13</span>
Twig Template
{{ bp.alert('info', '<h3>Heads up!</h3> This alert needs your attention, but it\'s not <a href="#">super important</a>.') }}
{{ bp.alert('danger', '<h3>Oh snap!</h3> Change a few things up and <a href="#">try submitting again</a>.', false) }}
Bootstrap HTML
<div class="alert alert-info alert-dismissable" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span></button>
<h3 class="alert-heading">Heads up!</h3> This alert needs your attention, but it's not <a href="#" class="alert-link">super important</a>.
</div>
<div class="alert alert-danger" role="alert">
<h3 class="alert-heading">Oh snap!</h3> Change a few things up and <a href="#" class="alert-link">try submitting again</a>.
</div>
Twig Template
{{ bp.progress(60, 'info', 'display') }}
{{ bp.progress([25, 25, 25, 25], ['', 'warning', 'success', 'danger striped']) }}
Bootstrap HTML
<div class="progress">
<div class="progress-bar progress-bar-info" style="width:60%;" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">60%</div>
</div>
<div class="progress">
<div class="progress-bar" style="width:25%;" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<span class="sr-only">25% Complete</span>
</div>
<div class="progress-bar progress-bar-warning" style="width:25%;" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<span class="sr-only">25% Complete</span>
</div>
<div class="progress-bar progress-bar-success" style="width:25%;" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<span class="sr-only">25% Complete</span>
</div>
<div class="progress-bar progress-bar-danger progress-bar-striped" style="width:25%;" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<span class="sr-only">25% Complete</span>
</div>
</div>
Twig Template
{{ bp.media([
'Image',
'<h1>Parent</h1> <p>Paragraph</p>',
'<img src="parent.jpg" alt="Family Photo">',
[
'Image',
'<h2>1st Child</h2>',
[
'Image',
'<h3>1st Grandchild</h3>',
],
],
[
'Image',
'<h2>2nd Child</h2>',
],
], [
'class': 'spoiled',
'Image',
'<h1>Sibling</h1> <a href="#">Link</a>',
'<img src="sibling.jpg" alt="Family Photo">',
]) }}
Bootstrap HTML
<div class="media">
<div class="media-left">Image</div>
<div class="media-body">
<h1 class="media-heading">Parent</h1>
<p>Paragraph</p>
<div class="media">
<div class="media-left">Image</div>
<div class="media-body">
<h2 class="media-heading">1st Child</h2>
<div class="media">
<div class="media-left">Image</div>
<div class="media-body">
<h3 class="media-heading">1st Grandchild</h3>
</div>
</div>
</div>
</div>
<div class="media">
<div class="media-left">Image</div>
<div class="media-body">
<h2 class="media-heading">2nd Child</h2>
</div>
</div>
</div>
<div class="media-right">
<img src="parent.jpg" alt="Family Photo" class="media-object">
</div>
</div>
<div class="media spoiled">
<div class="media-left">Image</div>
<div class="media-body">
<h1 class="media-heading">Sibling</h1>
<a href="#">Link</a>
</div>
<div class="media-right">
<img src="sibling.jpg" alt="Family Photo" class="media-object">
</div>
</div>
Twig Template
{{ bp.listGroup([
'Basic',
'List',
bp.badge(1) ~ ' Group',
]) }}
{{ bp.listGroup([
'Linked': '#',
'List': '#',
'Group ' ~ bp.badge(2): '#',
]) }}
{{ bp.listGroup([
'<h4>Custom</h4> <p>List</p>': '#',
bp.badge(3) ~ ' <h4>Group</h4> <p>Linked</p>': '#',
], 1) }}
Bootstrap HTML
<ul class="list-group">
<li class="list-group-item">Basic</li>
<li class="list-group-item">List</li>
<li class="list-group-item"><span class="badge">1</span> Group</li>
</ul>
<div class="list-group">
<a class="list-group-item" href="#">Linked</a>
<a class="list-group-item" href="#">List</a>
<a class="list-group-item" href="#">Group <span class="badge">2</span></a>
</div>
<div class="list-group">
<a class="list-group-item active" href="#">
<h4 class="list-group-item-heading">Custom</h4>
<p class="list-group-item-text">List</p>
</a>
<a class="list-group-item" href="#">
<span class="badge">3</span>
<h4 class="list-group-item-heading">Group</h4>
<p class="list-group-item-text">Linked</p>
</a>
</div>
Twig Template
{{ bp.panel('primary', [
'header': '<h3>Title</h3>',
'body': 'Content',
'footer': '<a href="#">Link</a>',
]) }}
{{ bp.panel('default', [
'header': 'List group',
bp.listGroup([
'One',
'Two',
'Three',
]),
]) }}
Bootstrap HTML
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Title</h3>
</div>
<div class="panel-body">Content</div>
<div class="panel-footer">
<a href="#">Link</a>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">List group</div>
<ul class="list-group">
<li class="list-group-item">One</li>
<li class="list-group-item">Two</li>
<li class="list-group-item">Three</li>
</ul>
</div>
Twig Template
{{ bp.toggle('tabs', [
'Home': 'One',
'Profile': 'Two',
'Dropdown': [
'This': 'Three',
'That': 'Four',
],
], [
'active': 'This',
'fade',
]) }}
Bootstrap HTML
<ul class="nav nav-tabs" role="tablist">
<li role="presentation"><a href="#tabsI" aria-controls="tabsI" role="tab" data-toggle="tab">Home</a></li>
<li role="presentation"><a href="#tabsII" aria-controls="tabsII" role="tab" data-toggle="tab">Profile</a></li>
<li class="dropdown active">
<a id="dropdownV" data-target="#" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" aria-labelledby="dropdownV">
<li role="presentation" class="active"><a role="menuitem" tabindex="-1" href="#tabsIII" data-toggle="tab">This</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#tabsIV" data-toggle="tab">That</a></li>
</ul>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade" id="tabsI">One</div>
<div role="tabpanel" class="tab-pane fade" id="tabsII">Two</div>
<div role="tabpanel" class="tab-pane fade in active" id="tabsIII">Three</div>
<div role="tabpanel" class="tab-pane fade" id="tabsIV">Four</div>
</div>
Twig Template
{{ bp.accordion('info', [
'<h4>Group Item #1</h4>': 'One',
'<h4>Group Item #2</h4>': 'Two',
'<h4>Group Item #3</h4>': 'Three',
], 2) }}
Bootstrap HTML
<div class="panel-group" id="accordionI" role="tablist" aria-multiselectable="true">
<div class="panel panel-info">
<div class="panel-heading" role="tab" id="headingII">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordionI" href="#collapseIII" aria-expanded="false" aria-controls="collapseIII">Group Item #1</a>
</h4>
</div>
<div id="collapseIII" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingII">
<div class="panel-body">One</div>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading" role="tab" id="headingIV">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordionI" href="#collapseV" aria-expanded="true" aria-controls="collapseV">Group Item #2</a>
</h4>
</div>
<div id="collapseV" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingIV">
<div class="panel-body">Two</div>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading" role="tab" id="headingVI">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordionI" href="#collapseVII" aria-expanded="false" aria-controls="collapseVII">Group Item #3</a>
</h4>
</div>
<div id="collapseVII" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingVI">
<div class="panel-body">Three</div>
</div>
</div>
</div>
Twig Template
<div style="width:500px; height:300px; margin:20px auto;">
{{ bp.carousel([
'<img src="http://lorempixel.com/500/300/food/1/" width="500" height="300">',
'<img src="http://lorempixel.com/500/300/food/2/" width="500" height="300">': '<p>Caption</p>',
'<img src="http://lorempixel.com/500/300/food/3/" width="500" height="300">': '<h3>Header</h3>',
], [
'interval': 3000,
]) }}
</div>
Bootstrap HTML
<div style="width:500px; height:300px; margin:20px auto;">
<div id="carouselI" class="carousel slide" data-ride="carousel" data-interval="3000">
<ol class="carousel-indicators">
<li data-target="#carouselI" data-slide-to="0" class="active"></li>
<li data-target="#carouselI" data-slide-to="1"></li>
<li data-target="#carouselI" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://lorempixel.com/500/300/food/1/" width="500" height="300">
</div>
<div class="item">
<img src="http://lorempixel.com/500/300/food/2/" width="500" height="300">
<div class="carousel-caption">
<p>Caption</p>
</div>
</div>
<div class="item">
<img src="http://lorempixel.com/500/300/food/3/" width="500" height="300">
<div class="carousel-caption">
<h3>Header</h3>
</div>
</div>
</div>
<a class="left carousel-control" href="#carouselI" role="button" data-slide="prev">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carouselI" role="button" data-slide="next">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-right"></span> <span class="sr-only">Next</span>
</a>
</div>
</div>