Bootstrap Flask screenshot

Bootstrap Flask

Author Avatar Theme by Helloflask
Updated: 2 May 2025
1159 Stars

Bootstrap 4 & 5 helper for your Flask projects.

Categories

Overview:

Bootstrap-Flask is a collection of Jinja macros designed to work with Bootstrap 4 & 5 and Flask, facilitating the rendering of Flask-related data and objects to Bootstrap markup HTML. It simplifies tasks such as rendering Flask-WTF/WTForms form objects to Bootstrap forms, data objects to Bootstrap tables, and Flask-SQLAlchemy Pagination objects to Bootstrap pagination. The extension streamlines the integration of Flask and Bootstrap elements, providing a more efficient development experience.

Features:

  • Jinja Macros for Bootstrap 4 & 5 and Flask: Simplifies rendering Flask-related data and objects to Bootstrap markup HTML.
  • Render Flask-WTF/WTForms Form Object to Bootstrap Form: Makes it easy to render Flask-WTF/WTForms form objects to Bootstrap forms.
  • Render Data Objects to Bootstrap Table: Enables the rendering of data objects (dict or class objects) to Bootstrap tables.
  • Render Flask-SQLAlchemy Pagination Object to Bootstrap Pagination: Streamlines the rendering of Flask-SQLAlchemy Pagination objects to Bootstrap pagination.

Installation:

To install Bootstrap-Flask, you can register the extension in your Flask application and utilize the provided macros. Here is an example of how to integrate the extension:

from flask import Flask
from flask_wtf import FlaskForm
from bootstrap_flask import Bootstrap
from wtforms import StringField, SubmitField

app = Flask(__name__)

# Register the Bootstrap extension
bootstrap = Bootstrap(app)

# Define a sample Flask-WTF form
class SampleForm(FlaskForm):
    name = StringField('Name')
    submit = SubmitField('Submit')

Now you can use the render_form macro in your template to render the form effortlessly:

{{/* render_form(form) */}}

For more installation details and usage examples, refer to the documentation.

Summary:

Bootstrap-Flask is a valuable collection of Jinja macros designed to enhance the integration between Flask and Bootstrap, making the rendering of Flask-related data and objects to Bootstrap markup HTML more straightforward. Through its features such as rendering Flask-WTF/WTForms form objects, data objects, and Flask-SQLAlchemy Pagination objects to Bootstrap elements, Bootstrap-Flask streamlines the development process by providing a convenient way to work with Flask and Bootstrap together. It offers support for both Bootstrap 4 and 5, with clear migration paths and detailed documentation available for developers.