Advanced Usage¶
Form Checkbox Customization¶
Rendering Switch¶
Bootstrap offers the rendering of a checkbox (or check) as a
switch. In
Bootstrap-Flask, simply use the built-in class SwitchField()
instead of
BooleanField()
. See also the example application.
Form Input Customization¶
Rendering Label¶
Bootstrap offers control for rendering
text. This is supported
for inputs of a form by adding render_kw={'label_class': '... ...'}
to the
field constructor. In order to control the rendering of the label of a field,
use render_kw={'label_class': '... ...'}
. See also the example application.
Rendering Radio Label¶
Similar support exists for the rendering of the labels of options of a
RadioField()` with ``render_kw={'radio_class': '... ...'}
. See also the
example application.
Rendering Description¶
Use render_kw={'description_class': '... ...'}
for controlling the
rendering of a field’s description. See also the example application.
Bootswatch Themes¶
Bootswatch is a collection of free and open source themes for Bootstrap. If you are using bootstrap.load_css()
to include
Bootstrap resources. Then you can set Bootswatch theme with configuration variable BOOTSTRAP_BOOTSWATCH_THEME
.
The available theme names are: ‘cerulean’, ‘cosmo’, ‘cyborg’, ‘darkly’, ‘flatly’, ‘journal’, ‘litera’, ‘lumen’, ‘lux’, ‘materia’, ‘minty’, ‘pulse’, ‘sandstone’, ‘simplex’, ‘sketchy’, ‘slate’, ‘solar’, ‘spacelab’, ‘superhero’, ‘united’, ‘yeti’.
For Bootstrap 5, besides these, you can also use: ‘morph’, ‘quartz’, ‘vapor’, ‘zephyr’.
Here is an example to use lumen
theme:
app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = 'lumen'
You can find these themes on https://bootswatch.com.