Skip to main content

A quick way to add Bootstrap Icons with Django template tags.

Project description

django-bootstrap-icons

A quick way to add Bootstrap Icons with Django template tags.

This package contains Bootstrap Icons v1.2.2 (Jan 2021).

The icons are embedded from the icon font. If you'd rather like to use the svg images try this one: django_bs_icons.

Installing

django-bootstrap-icons can be found on pypi. Run pip install django-bootstrap-icons to install the package on your machine.

Getting Started

Using django-bootstrap-icons is easy. First, install the django_material_icons Django app in your settings file.

INSTALLED_APPS = [
    'django_bootstrap_icons'
]

Also, include the following tags in your base template file. It includes the CDN link to the bootstrap icons web font. If you have your own source for the web font, feel free to opt out of this tag!

{% load django_bootstrap_icons %}

{% include_bootstrap_icons %}

Then, add an icon with the following tag. Give the name icon's name as the first parameter, and that's all that's required.

{% load django_bootstrap_icons %}

{% bs_icon 'alarm' %}

Icon styling

To style the icons, you can add extra css classes:

{% bs_icon 'alarm' extra_classes='your-class-name' %}

Sizing classes are included in the bootstrap icon css:

Icon sizes

{% bs_icon 'alarm' extra_classes='bi-xs' %}
{% bs_icon 'alarm' extra_classes='bi-sm' %}
{% bs_icon 'alarm' extra_classes='bi-2x' %}
{% bs_icon 'alarm' extra_classes='bi-3x' %}
{% bs_icon 'alarm' extra_classes='bi-5x' %}
{% bs_icon 'alarm' extra_classes='bi-7x' %}
{% bs_icon 'alarm' extra_classes='bi-10x' %}

If you have bootstrap css included, you can use the bootstrap color classes:

Icon colors

{% bs_icon 'alarm' extra_classes='text-success' %}
{% bs_icon 'alarm' extra_classes='text-info' %}
{% bs_icon 'alarm' extra_classes='text-warning' %}
{% bs_icon 'alarm' extra_classes='text-danger' %}
{% bs_icon 'alarm' extra_classes='text-primary' %}
{% bs_icon 'alarm' extra_classes='text-secondary' %}

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • Thanks bootstrap Icons!
  • Thanks to Doug Dresser dwdresser for the django_material_icon app that i used as a template

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-bootstrap-icons-0.2.5.tar.gz (307.6 kB view hashes)

Uploaded Source

Built Distribution

django_bootstrap_icons-0.2.5-py3-none-any.whl (304.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page