API Reference

class flask_bootstrap._Bootstrap(app=None)

Base extension class for different Bootstrap versions.

New in version 2.0.0.

bootstrap_css_filename = 'bootstrap.min.css'
bootstrap_css_integrity = None
bootstrap_js_filename = 'bootstrap.min.js'
bootstrap_js_integrity = None
bootstrap_version = None
init_app(app)
jquery_filename = 'jquery.min.js'
jquery_integrity = None
jquery_version = None
load_css(version=None, bootstrap_sri=None)

Load Bootstrap’s css resources with given version.

New in version 0.1.0.

Parameters

version – The version of Bootstrap.

load_js(version=None, jquery_version=None, popper_version=None, with_jquery=True, with_popper=True, bootstrap_sri=None, jquery_sri=None, popper_sri=None)

Load Bootstrap and related library’s js resources with given version.

New in version 0.1.0.

Parameters
  • version – The version of Bootstrap.

  • jquery_version – The version of jQuery (only needed with Bootstrap 4).

  • popper_version – The version of Popper.js.

  • with_jquery – Include jQuery or not (only needed with Bootstrap 4).

  • with_popper – Include Popper.js or not.

popper_filename = 'popper.min.js'
popper_integrity = None
popper_version = None
static_folder = None
class flask_bootstrap.Bootstrap4(app=None)

Extension class for Bootstrap 4.

Initialize the extension:

from flask import Flask
from flask_bootstrap import Bootstrap4

app = Flask(__name__)
bootstrap = Bootstrap4(app)

Or with the application factory:

from flask import Flask
from flask_bootstrap import Bootstrap4

bootstrap = Bootstrap4()

def create_app():
    app = Flask(__name__)
    bootstrap.init_app(app)

Changed in version 2.0.0: Move common logic to base class _Bootstrap.

bootstrap_css_integrity = 'sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn'
bootstrap_js_integrity = 'sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2'
bootstrap_version = '4.6.1'
jquery_integrity = 'sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0='
jquery_version = '3.5.1'
popper_integrity = 'sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN'
popper_name = 'popper.js'
popper_version = '1.16.1'
static_folder = 'bootstrap4'
class flask_bootstrap.Bootstrap5(app=None)

Base class for Bootstrap 5.

Initialize the extension:

from flask import Flask
from flask_bootstrap import Bootstrap5

app = Flask(__name__)
bootstrap = Bootstrap5(app)

Or with the application factory:

from flask import Flask
from flask_bootstrap import Bootstrap5

bootstrap = Bootstrap5()

def create_app():
    app = Flask(__name__)
    bootstrap.init_app(app)

New in version 2.0.0.

bootstrap_css_integrity = 'sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3'
bootstrap_js_integrity = 'sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13'
bootstrap_version = '5.1.3'
popper_integrity = 'sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB'
popper_name = '@popperjs/core'
popper_version = '2.10.2'
static_folder = 'bootstrap5'
class flask_bootstrap.SwitchField(*args, **kwargs)

A wrapper field for BooleanField that renders as a Bootstrap switch.

New in version 2.0.0.