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, nonce=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.

  • bootstrap_sri – The integrity attribute value of Bootstrap for SRI

  • jquery_sri – The integrity attribute value of jQuery for SRI

  • popper_sri – The integrity attribute value of Popper.js for SRI

  • nonce – The nonce attribute value for use with strict CSP

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-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi'
bootstrap_js_integrity = 'sha384-IDwe1+LCz02ROU9k972gdyvl+AESN10+x7tBKgc9I5HFtuNz0wWnPclzo6p9vxnk'
bootstrap_version = '5.2.2'
popper_integrity = 'sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3'
popper_name = '@popperjs/core'
popper_version = '2.11.6'
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.