API Reference¶
flask_font_awesome
Package¶
- class flask_font_awesome.FontAwesome(app=None)¶
Font Awesome icons for Flask.
- init_app(app)¶
Initialize the Flask application for use with this extension instance.
- load(version='6.7.2', style='all', css_sri='sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg==', core_css_sri='sha512-v8QQ0YQ3H4K6Ic3PJkym91KoeNT5S3PnDKvqnwqFD1oiqIl653crGZplPdU5KKtHjO0QKcQ2aUlQZYjHczkmGw==', js_sri='sha512-b+nQTCdtTBIRIbraqNEwsjB6UvL3UEMkXnhzd8awtCYh0Kcsjl9uEgwVFVbhoj3uu1DO1ZMacNvLoyJJiNfcvg==', core_js_sri='sha512-j12pXc2gXZL/JZw5Mhi6LC7lkiXL0e2h+9ZWpqhniz0DkDrO01VNlBrG3LkPBn6DgG2b8CDjzJT+lxfocsS1Vw==', use_min=True, use_css=False)¶
Load Font Awesome’s WebFonts + CSS / SVG + JS resources for the given version. Defaults to SVG + JS.
- Some examples:
>>> font_awesome.load() >>> font_awesome.load(style="solid", use_css=True) >>> font_awesome.load( ... version="5.9.0", ... js_sri="sha512-q3eWabyZPc1XTCmF+8/LuE1ozpg5xxn7iO89yfSOd5/oKvyqLngoNGsx8jq92Y8eXJ/IRxQbEC+FGSYxtk2oiw==" ... )
- Parameters:
version (str) – The version to load. Defaults to 6.2.0.
style (str) – The icon style(s) to load. Defaults to all.
css_sri (str) – The Subresource Integrity (SRI) for the CSS resource file when not served locally. Defaults to sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==.
core_css_sri (str) – The SRI for the core CSS resource file when not served locally. Defaults to sha512-uj2QCZdpo8PSbRGL/g5mXek6HM/APd7k/B5Hx/rkVFPNOxAQMXD+t+bG4Zv8OAdUpydZTU3UHmyjjiHv2Ww0PA==.
js_sri (str) –
The SRI for the JS resource file when not served locally. Defaults to sha512-naukR7I+Nk6gp7p5TMA4ycgfxaZBJ7MO5iC3Fp6ySQyKFHOGfpkSZkYVWV5R7u7cfAicxanwYQ5D1e17EfJcMA==.
core_js_sri (str) –
The SRI for the core JS resource file when not served locally. Defaults to sha512-j3gF1rYV2kvAKJ0Jo5CdgLgSYS7QYmBVVUjduXdoeBkc4NFV4aSRTi+Rodkiy9ht7ZYEwF+s09S43Z1Y+ujUkA==.
use_min (bool) – Whether to use the minified resource or not. Defaults to True.
use_css (bool) –
Whether to use WebFonts + CSS over SVG + JS. Defaults to False.
- Raises:
ValueError – When trying to load a non-free icon style (i.e. not one of all, regular, solid, or brands)
- Returns:
The HTML markup for the WebFonts + CSS / SVG + JS resource(s).
- Return type:
flask.Markup
- load_css(version='6.7.2', style='all', sri='sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg==', core_sri='sha512-v8QQ0YQ3H4K6Ic3PJkym91KoeNT5S3PnDKvqnwqFD1oiqIl653crGZplPdU5KKtHjO0QKcQ2aUlQZYjHczkmGw==', use_min=True)¶
Load Font Awesome’s WebFonts + CSS resources for the given version.
- Some examples:
>>> font_awesome.load_css() >>> font_awesome.load_css(style="regular")
- Parameters:
version (str) – The version to load. Defaults to 6.2.0.
style (str) –
The icon style(s) to load. Defaults to all.
sri (str) –
The Subresource Integrity (SRI) for the CSS resource file when not served locally. Defaults to sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==.
core_sri (str) –
The SRI for the core CSS resource file when not served locally. Defaults to sha512-uj2QCZdpo8PSbRGL/g5mXek6HM/APd7k/B5Hx/rkVFPNOxAQMXD+t+bG4Zv8OAdUpydZTU3UHmyjjiHv2Ww0PA==.
use_min (bool) – Whether to use the minified resources or not. Defaults to True.
- Raises:
ValueError – When trying to load a non-free icon style (i.e. not one of all, regular, solid, or brands)
- Returns:
The HTML markup for the WebFonts + CSS resources.
- Return type:
flask.Markup
- load_js(version='6.7.2', style='all', sri='sha512-b+nQTCdtTBIRIbraqNEwsjB6UvL3UEMkXnhzd8awtCYh0Kcsjl9uEgwVFVbhoj3uu1DO1ZMacNvLoyJJiNfcvg==', core_sri='sha512-j12pXc2gXZL/JZw5Mhi6LC7lkiXL0e2h+9ZWpqhniz0DkDrO01VNlBrG3LkPBn6DgG2b8CDjzJT+lxfocsS1Vw==', use_min=True)¶
Load Font Awesome’s SVG + JS resource for the given version.
- Some examples:
>>> font_awesome.load_js() >>> font_awesome.load_js( ... use_min=False, ... sri="sha512-8XtSBQOB+R4dpcpQBpYC5Q7ti7y/MjIF0l/1ZiSd4xM04Dr052S/Py981Pzmwo2HrXCR2JhYE1MYR15aZGMnig==" ... )
- Parameters:
version (str) – The version to load. Defaults to 6.2.0.
style (str) –
The icon style(s) to load. Defaults to all.
sri (str) –
The SRI for the JS resource file when not served locally. Defaults to sha512-naukR7I+Nk6gp7p5TMA4ycgfxaZBJ7MO5iC3Fp6ySQyKFHOGfpkSZkYVWV5R7u7cfAicxanwYQ5D1e17EfJcMA==.
core_sri (str) –
The SRI for the core JS resource file when not served locally. Defaults to sha512-j3gF1rYV2kvAKJ0Jo5CdgLgSYS7QYmBVVUjduXdoeBkc4NFV4aSRTi+Rodkiy9ht7ZYEwF+s09S43Z1Y+ujUkA==.
use_min (bool) – Whether to use the minified resource or not. Defaults to True.
- Raises:
ValueError – When trying to load a non-free icon style (i.e. not one of all, regular, solid, or brands)
- Returns:
The HTML markup for the SVG + JS resource.
- Return type:
flask.Markup
- render_icon(name, inverse=False, size=None, fixed_with=False, rotation=None, animation=None, border=False, pull=None, swap_opacity=False, aria_hidden=True, style=None, _stack_size=None)¶
Render an icon.
See the Font Awesome documentation for the complete list of available icons.
- Some examples:
>>> font_awesome.render_icon('fas fa-house') >>> font_awesome.render_icon('fa-regular fa-square', size='xl') >>> font_awesome.render_icon('fab fa-github', inverse=True, rotation=90)
- Parameters:
name (str) – The name of the icon (e.g. fa-solid fa-user).
inverse (bool) – Inverts the color of the icon to white. Defaults to False.
size (Optional[str]) – The relative or literal size of the icon. Defaults to None.
fixed_with (bool) – Set the icon to a fixed width for easy vertical alignment. Defaults to False.
rotation (Optional[Union[str, int]]) – Rotate or flip the icon. Defaults to None.
animation (Optional[str]) – Animate the icon. Defaults to None.
border (bool) – Add a border to the icon. Defaults to False.
pull (Optional[str]) – Pull the icon left or right. Defaults to None.
swap_opacity (bool) – Swap the default opacity of each layer in a duotone icon. Defaults to False.
aria_hidden (bool) – Add the aria-hidden attribute to the icon. Defaults to True.
style (Optional[str]) – Customize the icon even further using CSS styling. Defaults to None.
- Returns:
The HTML markup for the icon.
- Return type:
flask.Markup
- render_stacked_icon(name_1, name_2, stack_size_1='2x', stack_size_2='1x', inverse=False, size=None, aria_hidden=True, style=None, style_1=None, style_2=None)¶
Render a stacked icon.
- Some examples:
>>> font_awesome.render_stacked_icon( ... "fa-solid fa-square", ... "fab fa-twitter", ... inverse=True, ... size="2x", ... ) >>> font_awesome.render_stacked_icon( ... "fa-solid fa-camera", ... "fa-solid fa-ban", ... stack_size_1="1x", ... stack_size_2="2x", ... size="2x", ... style_2="color:Tomato", ... )
- Parameters:
name_1 (str) – The name of the first icon (e.g. fa-solid fa-square).
name_2 (str) – The name of the second icon (e.g. fab fa-twitter).
stack_size_1 (str) – The relative size of the first icon. One of 1x or 2x. Defaults to 2x.
stack_size_2 (str) – The relative size of the second icon. One of 1x or 2x. Defaults to 1x.
inverse (bool) – Inverts the color of the icon to white. Defaults to False.
size (Optional[str]) –
The relative or literal size of the stacked icon. Defaults to None.
aria_hidden (bool) – Add the aria-hidden attribute to the icon. Defaults to True.
style (Optional[str]) –
Customize the stacked icon even further using CSS styling. Defaults to None.
style_1 (Optional[str]) –
Customize the first icon even further using CSS styling. Defaults to None.
style_2 (Optional[str]) –
Customize the second icon even further using CSS styling. Defaults to None.
- Returns:
The HTML markup for the icon.
- Return type:
flask.Markup