sanketsaurav / django-octicons

Django template tags for GitHub Octicons.
https://pypi.org/project/django-octicons
MIT License
15 stars 4 forks source link
django octicons octicons-helper templatetags

django-octicons

PyPI Build Status Python Versions License

Django template tags for using GitHub Octicons, with no other dependencies.

Installation

Grab it from PyPI using pipenv (or pip):

$ pipenv install django-octicons

Install the app in your project:

# settings.py

INSTALLED_APPS = [
    # other apps
    'octicons',
]

Usage

Load the tag library in your HTML template:

{% load octicons %}

And then, you can use the icons like this:

<a class="btn btn-sm" href="#url" role="button">
  {% octicon "eye" %}
  Watch
</a>

You can also pass required height and width for the icon like this:

<a class="btn btn-sm" href="#url" role="button">
  {% octicon "thumbsup" height="60" width="60" class="large" %}
  Confirm Purchase
</a>

Or, you can scale the icon with respect to its default dimensions like this:

<a class="btn btn-sm" href="#url" role="button">
  {% octicon "thumbsup" scale=2 class="large" %}
  Confirm Purchase
</a>

All attributes passed will be added as HTML attributes to the SVG element of the icon.

Styling

You should add the following in your styles:

.octicon {
  display: inline-block;
  vertical-align: text-top;
  fill: currentColor;
}

The class octicon will be present in all icons. You are free to style it however you want.