API Reference

class flask_bootstrap._Bootstrap(app=None)

Base extension class for different Bootstrap versions.

Added 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
icons_version = None
init_app(app)
jquery_filename = 'jquery.min.js'
jquery_integrity = None
jquery_version = None
load_css(version=None, bootstrap_sri=None, bootswatch_theme=None)

Load Bootstrap’s css resources with given version.

Added in version 0.1.0.

Parameters:
  • version – The version of Bootstrap.

  • bootswatch_theme – Set the bootswatch theme at the request/session level.

load_icon_font_css()

Load Bootstrap’s css icon font resource.

Added in version 2.4.2.

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.

Added 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-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N'
bootstrap_js_integrity = 'sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+'
bootstrap_version = '4.6.2'
icons_version = '1.13.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)

Added in version 2.0.0.

bootstrap_css_integrity = 'sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB'
bootstrap_js_integrity = 'sha384-G/EV+4j2dNv+tEPo3++6LCgdCROaejBqfUeNjuKAiuXbjrxilcCdDz6ZAVfHWe1Y'
bootstrap_version = '5.3.8'
icons_version = '1.13.1'
popper_integrity = 'sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r'
popper_name = '@popperjs/core'
popper_version = '2.11.8'
static_folder = 'bootstrap5'
class flask_bootstrap.SwitchField(*args, **kwargs)

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

Added in version 2.0.0.