Bootstrap Icons are SVGs, so you can include them into your HTML in a few ways depending on how your project is setup. Bootstrap Icons include a width and height of 1em by default to allow for easy resizing via font-size. We provide compiled CSS and JS (bootstrap.), as well as compiled and minified CSS and JS (bootstrap.min.). Source maps (bootstrap.map) are available for use with certain browsers' developer tools. Bundled JS files (bootstrap.bundle.js and minified bootstrap.bundle.min.js) include Popper, but not jQuery. Bugs and feature requests. Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles. Bootstrap is the most popular HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web. Download Bootstrap Currently v4.0.0-alpha.6.
DataTables can integrate seamlessly with Bootstrap 3 using Bootstrap's table styling options to present an interface with a uniform design, based on Bootstrap, for your site / app.
DataTables' Bootstrap integration also provides a renderer for the pagination control in DataTables to ensure that the pagination of the table is also styled consistently by Bootstrap.
This integration is done simply by including the DataTables Bootstrap files (CSS and JS) which sets the defaults needed for DataTables to be initialised as normal, as shown in this example.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Herrod Chandler | Sales Assistant | San Francisco | 59 | 2012/08/06 | $137,500 |
Rhona Davidson | Integration Specialist | Tokyo | 55 | 2010/10/14 | $327,900 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Jena Gaines | Office Manager | London | 30 | 2008/12/19 | $90,560 |
Quinn Flynn | Support Lead | Edinburgh | 22 | 2013/03/03 | $342,000 |
Charde Marshall | Regional Director | San Francisco | 36 | 2008/10/16 | $470,600 |
Haley Kennedy | Senior Marketing Designer | London | 43 | 2012/12/18 | $313,500 |
Tatyana Fitzpatrick | Regional Director | London | 19 | 2010/03/17 | $385,750 |
Michael Silva | Marketing Designer | London | 66 | 2012/11/27 | $198,500 |
Paul Byrd | Chief Financial Officer (CFO) | New York | 64 | 2010/06/09 | $725,000 |
Gloria Little | Systems Administrator | New York | 59 | 2009/04/10 | $237,500 |
Bradley Greer | Software Engineer | London | 41 | 2012/10/13 | $132,000 |
Dai Rios | Personnel Lead | Edinburgh | 35 | 2012/09/26 | $217,500 |
Jenette Caldwell | Development Lead | New York | 30 | 2011/09/03 | $345,000 |
Yuri Berry | Chief Marketing Officer (CMO) | New York | 40 | 2009/06/25 | $675,000 |
Caesar Vance | Pre-Sales Support | New York | 21 | 2011/12/12 | $106,450 |
Doris Wilder | Sales Assistant | Sydney | 23 | 2010/09/20 | $85,600 |
Angelica Ramos | Chief Executive Officer (CEO) | London | 47 | 2009/10/09 | $1,200,000 |
Gavin Joyce | Developer | Edinburgh | 42 | 2010/12/22 | $92,575 |
Jennifer Chang | Regional Director | Singapore | 28 | 2010/11/14 | $357,650 |
Brenden Wagner | Software Engineer | San Francisco | 28 | 2011/06/07 | $206,850 |
Fiona Green | Chief Operating Officer (COO) | San Francisco | 48 | 2010/03/11 | $850,000 |
Shou Itou | Regional Marketing | Tokyo | 20 | 2011/08/14 | $163,000 |
Michelle House | Integration Specialist | Sydney | 37 | 2011/06/02 | $95,400 |
Suki Burks | Developer | London | 53 | 2009/10/22 | $114,500 |
Prescott Bartlett | Technical Author | London | 27 | 2011/05/07 | $145,000 |
Gavin Cortez | Team Leader | San Francisco | 22 | 2008/10/26 | $235,500 |
Martena Mccray | Post-Sales support | Edinburgh | 46 | 2011/03/09 | $324,050 |
Unity Butler | Marketing Designer | San Francisco | 47 | 2009/12/09 | $85,675 |
Howard Hatfield | Office Manager | San Francisco | 51 | 2008/12/16 | $164,500 |
Hope Fuentes | Secretary | San Francisco | 41 | 2010/02/12 | $109,850 |
Vivian Harrell | Financial Controller | San Francisco | 62 | 2009/02/14 | $452,500 |
Timothy Mooney | Office Manager | London | 37 | 2008/12/11 | $136,200 |
Jackson Bradshaw | Director | New York | 65 | 2008/09/26 | $645,750 |
Olivia Liang | Support Engineer | Singapore | 64 | 2011/02/03 | $234,500 |
Bruno Nash | Software Engineer | London | 38 | 2011/05/03 | $163,500 |
Sakura Yamamoto | Support Engineer | Tokyo | 37 | 2009/08/19 | $139,575 |
Thor Walton | Developer | New York | 61 | 2013/08/11 | $98,540 |
Finn Camacho | Support Engineer | San Francisco | 47 | 2009/07/07 | $87,500 |
Serge Baldwin | Data Coordinator | Singapore | 64 | 2012/04/09 | $138,575 |
Zenaida Frank | Software Engineer | New York | 63 | 2010/01/04 | $125,250 |
Zorita Serrano | Software Engineer | San Francisco | 56 | 2012/06/01 | $115,000 |
Jennifer Acosta | Junior Javascript Developer | Edinburgh | 43 | 2013/02/01 | $75,650 |
Cara Stevens | Sales Assistant | New York | 46 | 2011/12/06 | $145,600 |
Hermione Butler | Regional Director | London | 47 | 2011/03/21 | $356,250 |
Lael Greer | Systems Administrator | London | 21 | 2009/02/27 | $103,500 |
Jonas Alexander | Developer | San Francisco | 30 | 2010/07/14 | $86,500 |
Shad Decker | Regional Director | Edinburgh | 51 | 2008/11/13 | $183,000 |
Michael Bruce | Javascript Developer | Singapore | 29 | 2011/06/27 | $183,000 |
Donna Snider | Customer Support | New York | 27 | 2011/01/25 | $112,000 |
Name | Position | Office | Age | Start date | Salary |
- Javascript
- HTML
- CSS
- Ajax
- Server-side script
- Comments
The Javascript shown below is used to initialise the table shown in this example:
$(document).ready(function() { $('#example').DataTable();} );
In addition to the above code, the following Javascript library files are loaded for use in this example:
The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:
This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The additional CSS used is shown below:
The following CSS library files are loaded for use in this example to provide the styling of the table:
This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is loaded.
The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side processing scripts can be written in any language, using the protocol described in the DataTables documentation.
Other examples
Basic initialisation
Advanced initialisation
Styling
Data sources
API
Ajax
Server-side
Plug-ins
- Vue.js
v2.6
is required,v2.6.12
is recommended - Bootstrap
v4.3.1
is required,v4.5.3
is recommended - Popper.js
v1.16
is required for dropdowns (and components based on dropdown), tooltips, and popovers.v1.16.1
is recommended - PortalVue
v2.1
is required by Toasts,v2.1.7
is recommended - jQuery is not required
Check out what is new in BootstrapVue release v2.21.2.
If you are migrating from a previous v2.0.0-rc.##
release, please see the v2.0.0
migration guide.
Documentation sections
The online documentation comprises:
- Components - Components and component plugin documentation
- Directives - Directives and directive plugin documentation
- Icons - Icons and icon plugin documentation v2.2.0+
- Reference - Reference information and documentation
- Playground - Online playground
- Themes - Themes and dashboards
Prerequisites
This BootstrapVue documentation assumes you are familiar with Vue and and Bootstrap v4 CSS. Good starting points for these:
- Vue loader scoped CSS, if using scoped styles in SFC (Single File Component)
.vue
files
Documentation information
In many of the examples shown in BootstrapVue's documentation, you may see the use of CSS classes such as ml-2
, py-1
, etc. These are Bootstrap v4.5 utility classes that help control padding, margins, positioning and more. You can find information on these classes in the Utility Classes reference section.
Many of the examples in this documentation are live and can be edited in-place for an enhanced learning experience (note some examples may not work in IE 11 due to use of ES6 JavaScript code in the <template>
sections).
BootstrapVue also provides an interactive playground where you can experiment with the various components and export your results to JSFiddle, CodePen, and/or CodeSandbox.
Important HTML globals
Bootstrap v4 CSS employs a handful of important global styles and settings that you'll need to be aware of when using it, all of which are almost exclusively geared towards the normalization of cross browser styles. Refer to the following sub-sections for details.
HTML5 doctype
Bootstrap requires the use of the HTML5
doctype. Without it, you may see some strange incomplete styling.
Responsive meta tag
Bootstrap is optimized for mobile devices first and then scales up components as necessary using CSS media queries. To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>
.
CSS box-sizing
For more straightforward sizing in CSS, the global box-sizing
value is switched from content-box
to border-box
. This ensures padding
does not affect the final computed width of an element, but it can cause problems with some third party software like Google Maps and Google Custom Search Engine.
On the rare occasion you need to override it, use something like the following:
With the above snippet, nested elements — including generated content via ::before
and ::after
— will all inherit the specified box-sizing
for that .selector-for-some-widget
.
Learn more about box model and sizing at CSS Tricks.
Style reboot
For improved cross-browser rendering, Bootstrap v4.5 uses Reboot to correct inconsistencies across browsers and devices while providing slightly more opinionated resets to common HTML elements.
Using module bundlers
Most likely you are using module bundlers like Webpack, Parcel or rollup.js, which makes it easy to directly include the package into your project. To do this, use npm
or yarn
to get the latest version of Vue.js, Bootstrap v4 and BootstrapVue:
Then, register BootstrapVue in your app entry point (typically app.js
or main.js
):
Theming Bootstrap
If you want to change Bootstrap's default styles (e.g. the $body-color
), you have to use Bootstrap's and BootstrapVue's scss
files.
Create your own scss
file (e.g. app.scss
) containing both your custom definitions and the 2 @import
's at the end:
Then import that single scss
file into your project:
Do not import the individual SCSS files separately into your project, because variables and functions will fail to be shared between files.
For information on theming Bootstrap, check out the Theming reference section.
Aliasing Vue import
BootstrapVue and PortalVue require access to the global Vue
reference (via import Vue from 'vue'
).
If you are using a specific build of Vue (i.e. runtime-only vs. compiler + runtime), you will need to set up an alias to 'vue'
in your bundler config to ensure that your project, BootstrapVue and PortalVue are all using the same build version of Vue. If you are seeing an error such as '$attr and $listeners is readonly'
, or 'Multiple instances of Vue detected'
, then you will need to set up an alias.
Example: Vue alias for Vue CLI in vue.config.js
Example: Vue alias in webpack.config.js
Note: If your project has multiple webpack config files (i.e. webpack.config.js
, webpack.renderer.config.js
, webpack.vendor.config.js
, webpack.server.config.js
, webpack.client.config.js
, etc.), you will need to set the appropriate alias in all of them.
See the Vue.js Guide for full details on setting up aliases for webpack, rollup.js, Parcel, etc.
Advanced module bundler usage
Webpack and Parcel support prepending the scss
modules with tilde paths (~
) when importing from a scss
file:
For more details how to configure asset loading and how modules are resolved, please consult the module bundlers documentation.
Notes:
- Webpack configuration to load CSS files (official guide)
- Webpack Loader for SASS/SCSS files (official guide)
- Parcel CSS (official guide)
- Parcel SCSS (official guide)
Tree shaking with module bundlers
When using a module bundler you can optionally import only specific components groups (plugins), components and/or directives. Note that tree shaking only applies to the JavaScript code and not CSS/SCSS.
Note: Optimal tree shaking only works when webpack 4 is in production
mode and javascript minification is enabled.
Component groups and directives as Vue plugins
You can import component groups and directives as Vue plugins by importing from the bootstrap-vue
:
When importing as plugins, all subcomponents and related directives are imported in most cases. i.e. When importing <b-nav>
, all the <nav-*>
sub components are also included, as well all dropdown sub components. Component shorthand aliases (if any) are also included in the plugin. Refer to the component and directive documentation for details.
There are two additional helper plugins for providing the $bvModal
and $bvToast
injections (if you are not using the ModalPlugin
or ToastPlugin
plugins) which are available for import from 'bootstrap-vue'
:
BVModalPlugin
- provides the injection$bvModal
for generating message boxes.BVToastPlugin
- provides the injection$bvToast
for generating on demand toasts.
When importing multiple component group and/or directive group plugins, include all imports in a single import
statement for optimal tree shaking.
Individual components and directives
If you would like to only pull in a specific component or set of components, you can do this by directly importing those components.
To cherry pick a component/directive, start by importing it in the file where it is being used:
Then add it to your component definition:
Or register them globally:
Vue allows for various component and directive name syntaxes here, so feel free to utilize kebab-casing (shown), camelCasing, PascalCasing, and/or object property shorthand (components only).
Using BootstrapVue source code for smaller bundles
When using module bundlers, they will usually default to using the esm/
modular build, which has been pre-transpiled by Babel for our supported browsers.
You can override the use of the esm/
build by aliasing 'bootstrap-vue'
to use the BootstrapVue source files, and whitelisting node_modules/bootstrap-vue/src/*
for transpilation by your build process, in your module bundler config. This will allow you to transpile BootstrapVue for your target browsers/environments and potentially reduce bundle sizes (and will only include the babel helper utils once) at the expense of slightly longer build times.
Example webpack.config.js for Babel transpilation:
You may need to install babel-core
, babel-loader
, and babel-preset-env
:
For more details see:
Nuxt.js module
BootstrapVue provides a Nuxt.js module for easily importing BootstrapVue (or portions of BootstrapVue) into your Nuxt.js app.
Bootstrap Cdn
Getting started with Nuxt.js
Nuxt.js version 2.14.12
(or greater) is recommended.
Install dependencies:
Add bootstrap-vue/nuxt
to modules section of your nuxt.config.js
file.
This will include both bootstrap.css
and bootstrap-vue.css
default pre-compiled CSS.
Note that this will not install the Icons components. To see how to include icons via the Nuxt.js module, refer to the Icons section below.
Using custom Bootstrap SCSS
If you are using custom Bootstrap SCSS, you can disable automatic inclusion of Bootstrap and BootstrapVue pre-compiled CSS files by setting the following option(s) to false
:
BootstrapVue's custom SCSS relies on Bootstrap SCSS variables and mixins, and any variable overrides you may have set. You can include Bootstrap and BootstrapVue SCSS in your project's custom SCSS file:
In your app main entry point include the single custom SCSS file (when using sass-loader
):
transformAssetUrls
with Nuxt.js
The BootstrapVue Nuxt plugin module will automatically add in the BootstrapVue specific transformAssetUrls
image src
prop configuration for you.
Tree shaking with Nuxt.js
If you wish to reduce your production bundle size because you only use a subset of the available BootstrapVue plugins, you can configure the list of BootstrapVue componentPlugins
or directivePlugins
you want to globally install in your Nuxt.js project. Note tree shaking only applies to the JavaScript code and not CSS/SCSS.
There are two additional helper plugins for providing the $bvModal
and $bvToast
injections (if you are not using the ModalPlugin
or ToastPlugin
plugins) that are available in the componentPlugins
option:
BVModalPlugin
- provides the injection$bvModal
for generating message boxes.BVToastPlugin
- provides the injection$bvToast
for generating on demand toasts.
You can also optionally import individual components and/or directives, by configuring the list of BootstrapVue components
or directives
you want to globally install in your Nuxt.js project.
Bootstrap Min Width
Feel free to mix and match plugin imports with individual component and directive imports.
Refer to the reference section at the bottom of each of the component and directive docs for details on the plugin names available (and which components and directives are included in each plugin) and component and/or directive import names.
Note that when importing individual components, any component aliases will not be available.
Note: Optimal tree shaking only works when your Nuxt.js app is in production
mode. You may notice larger bundle sizes when not in production
mode (i.e. dev
mode).
If you want to import individual BootstrapVue components into specific pages and/or components of your Nuxt app, you may want to bypass the Nuxt.js module and, instead, follow the module bundlers and Tree shaking with module bundlers sections above. Alternatively you may want to to just import a few plugins (such as LayoutPlugin
) in your Nuxt.js module config, and then import additional components or plugins in the pages where needed.
Icons
The icons plugin is not automatically installed when using the Nuxt.js module. You must either explicitly enable the IconsPlugin
, or specify which icon components you wish to import.
All Icons:
Specific icons:
Icons plugin:
Passing custom BootstrapVue config with Nuxt.js
If you need to pass a custom BootstrapVue configuration, you may do so by setting the config
property in your nuxt.config.js
:
Using pretranspiled version of BootstrapVue for Nuxt.js
Nuxt.js module uses the pre-transpiled versions of BootstrapVue for faster development builds and the source (src/
) of BootstrapVue for higher quality and smaller production builds.
You can override this option using usePretranspiled
option. Setting to true
always uses the pre-transpiled versions, while setting it to false
will always use src/
. By default usePretranspiled
is enabled in development mode only. You should not need to use this option as the default is most optimal for performance.
Vue CLI 3
Unlike V2, Vue CLI 3 doesn't use templates.
Create a new project in the directory my-project
:
Enter the my-project
directory and install bootstrap-vue
:
Under the hood, Vue CLI uses webpack, so we can register the BootstrapVue plugin as with the webpack instructions.
For additional configuration for Vue CLI 3 for using project relative paths for image src props on various BootstrapVue components, refer to the Vue CLI 3 section of the Image Src Resolving reference page.
Bootstrap Minimal
Vue CLI 3 plugin
As an alternative, you can use the Bootstrap-Vue Vue CLI 3 plugin to help you configure your app.
This will create a new app with basic BootstrapVue settings to get your project started.
In the future this plugin will provide options for more advanced configurations and templates.
For Icons support, you may need to edit the resultant config file.
Browser
If not using a module bundler or compile process, you can instead add the Bootstrap and BootstrapVue CSS URLs in your HTML <head>
section, followed by the required JavaScript files.
When supporting older browsers (see Browser Support below), you will need to include a polyfill for handling modern JavaScript features before loading Vue and BootstrapVue JavaScript files.
Build variants
Choosing the best variant for your build environment / packager helps reduce bundle sizes. If your bundler supports esm modules, it will automatically prefer it over commonjs.
Variant | Environments | Tree Shake | Package path |
---|---|---|---|
ESM module | webpack 2+ / rollup.js | Yes | esm/index.js |
ESM bundle | webpack 2+ / rollup.js | Yes | dist/bootstrap-vue.esm.js |
commonjs2 | webpack 1 / ... | No | dist/bootstrap-vue.common.js ordist/bootstrap-vue.common.min.js |
UMD | Browser | No | dist/bootstrap-vue.js ordist/bootstrap-vue.min.js |
Note the UMD (browser) variant does not include BootstrapVue icons support. All other variants listed above do include the BootstrapVueIcons
(IconsPlugin
) plugin (note the icons plugin is not automatically installed, and must explicitly installed via Vue.use()
. See the Icons usage section for more details.
Icons only modules:
Variant | Environments | Tree Shake | Package path |
---|---|---|---|
ESM bundle | webpack 2+ / rollup.js | Yes | dist/bootstrap-vue-icons.esm.js |
commonjs2 | webpack 1 / ... | No | dist/bootstrap-vue-icons.common.js ordist/bootstrap-vue-icons.common.min.js |
UMD | Browser | No | dist/bootstrap-vue-icons.js ordist/bootstrap-vue-icons.min.js |
The ESM
module build and the ESM
bundles (single file) are tree-shakeable, but you will experience smaller final bundle sizes when using the ESM
module vs. the ESM
bundle.
All of the build variants listed above have been pre-transpiled targeting the browsers supported by BootstrapVue. However, if you are targeting only modern browsers, you may want to import BootstrapVue
from src/index.js
, (by aliasing bootstrap-vue
to bootstrap-vue/src/index.js
) and whitelisting bootstrap-vue/src
for transpilation via your own project. This can potentially reduce final project bundle sizes. See the Using BootstrapVue source code for smaller bundles section above for more details.
Dependencies
BootstrapVue relies on Popper.js
(for Tooltip, Popover, and Dropdown positioning), PortalVue
(for toasts) and vue-functional-data-merge
(used by our functional components). These three dependencies are included in the BootstrapVue UMD
bundle, while the UMD (browser) icons only bundle includes vue-functional-data-merge
. All other builds do not include these dependencies.
Migrating a project already using Bootstrap
If you've already been using Bootstrap v4, there are a couple adjustments you may need to make to your project:
- Remove the
bootstrap.js
file from your page scripts or build pipeline - If Bootstrap is the only thing relying on
jQuery
, you can safely remove it — BootstrapVue does not depend onjQuery
- Convert your native Bootstrap HTML markup into the simplified BootstrapVue custom component markup
- Start by converting only the interactive controls that require Bootstrap's javascript first.
Browser support
CSS
BootstrapVue is to be used with Bootstrap v4.5 CSS/SCSS. Please see Browsers and devices for more information about browsers currently supported by Bootstrap v4.
JS
BootstrapVue is written in Vue.js! So it is up to your project and bundler which browsers are supported.
Following features and APIs are used by BootstrapVue:
- ES6 (e.g.
Array.from()
,Array.isArray()
,Object.assign()
,Object.is()
, etc.) Promise
MutationObserver
IntersectionObserver
(optional)
If you want to support older IE, Android, and iOS device web browsers, you may want to use core-js and intersection-observer:
Then import the polyfills in your app main entry point:
If using deprecated @babel/polyfill:
Then import the polyfills in your app main entry point:
Alternatively, use Polyfill.io to dynamically serve browser specific polyfills via <script>
tags in the HTML <head>
section. See the Browser section above for an example.
Tooling support
BootstrapVue provides additional helper files for auto completion in popular IDE editors.
VS Code + Vetur
If you are using VS Code as your text editor, BootstrapVue has intellisense autocompletion for component attributes and directives available via the dist/vetur-tags.json
and dist/vetur-attributes.json
files.
JetBrains WebStorm (and compatible)
For WebStorm editor (or web-types compatible), BootstrapVue provides the file dist/web-types.json
for component attribute and directive auto-completion.