Install the addon if you have not done so already:
ember install ember-bootstrap
To allow Bootstrap to render modals and tooltips, add
<div id="ember-bootstrap-wormhole"></div>
to either the
app/index.html
or
app/templates/application.hbs
.
To use ember-bootstrap, include Bootstrap's style sheets into your app's build configuration.
For classic apps, add the following to your
ember-cli-build.js
:
let app = new EmberApp(defaults, { /* Configuration */ });
app.import('node_modules/bootstrap/dist/css/bootstrap.css');
app.toTree();
For apps using Embroider, import the CSS in
app/app.js
.
import 'bootstrap/dist/css/bootstrap.css';
See the
Ember documentation
for more information about including assets into your app.
By default, ember-bootstrap installs Bootstrap 5 and uses the installed preprocessor if there is one. You can use the ember-bootstrap default blueprint to switch the Bootstrap version or preprocessor.
To use a Sass as a CSS preprocessor instead of plain CSS (highly recommended!), you can use this command to install and set this up:
ember generate ember-bootstrap --preprocessor=sass
See the Assets guide for details.
You can switch to Bootstrap 5 by running this command:
ember generate ember-bootstrap --bootstrap-version=5
The default blueprint does the following:
package.json
and
bower.json
ember-cli-sass
and
app.scss
if appropriate
app.scss
if it's not there already
ember-cli-build.js
to ensure the proper ember-bootstrap settings for your configuration
Besides the above-mentioned configuration options that are handled explicitly using the default blueprint, you can further customize your setup with the following options:
Option | Allowed values | Default | Description |
---|---|---|---|
bootstrapVersion | 4 / 5 | 5 |
Specify the Bootstrap version to use. To make sure you have the right dependencies installed, you should use the default blueprint mentioned above to set this! |
importBootstrapCSS | true / false |
true if no preprocessor |
Include the default static
See the Assets guide for more details. |
include | Array of component names |
Component tree shaking: include only the listed components into your
build, to reduce your JavaScript bundle size. Components not listed
here will not be available. You should use either
Example:
|
|
exclude | Array of component names |
Exclude the listed components from your build, to reduce your
JavaScript bundle size. See
|
These options can be set in your ember-cli-build.js
file:
//your-bootstrap-app/ember-cli-build.js
module.exports = function(defaults) { let app = new EmberApp(defaults, {
'ember-bootstrap': { importBootstrapCSS: false, exclude: ['bs-popover',
'bs-accordion'] } }); return app.toTree(); };