Skip to main content

Django SVG Icons made easy

Project description

Django SVG Icons
================

Simple django templatetag to display `SVG` icons in your django application.
Icon paths will loaded from a provided `JSON` file, formatted according the icomoon format.

More info: [Icomoon website](http://icomoon.io/)


Installation
------------

Installation from pypi via pip

pip install django-svg-icons


Configuration
-------------

In your django project add `svg_icons` to your installed apps and set the `SVG_ICONS_SOURCE_FILE` setting to your source file.

INSTALLED_APPS = [
# ...
'svg_icons',
]

SVG_ICONS_SOURCE_FILE = '/path/to/source_file.json'

### Settings

Configuration and defaults of the templatetag are defined in django settings.

#### SVG_ICONS_READER_CLASS
_default: `svg_icons.readers.icomoon.IcomoonReader`_<br/>
Reader class to load the SVG data file and serve the right icon data

#### SVG_ICONS_SOURCE_FILE
Location of the (icomoon formatted) source file which contains the paths of all `svgs`

#### SVG_ICONS_DEFAULT_WIDTH
_default: 22_<br/>
Default width which gets set when no width or size is provided.

#### SVG_ICONS_DEFAULT_HEIGHT
_default: 22_<br/>
Default height which gets set when no height or size is provided.


Usage
-----

In your templates you can load the templatetag and start including your icons.

{% load svg_icons %}
{% icon 'icon_name' %}

The templatetag accepts some kwargs for icon configuration as well.

- **size** for setting both width and height
- **width** for only setting a specific width
- **height** for only setting a specific height
- **className** css classnames applied on the `<svg>` object

All kwargs are optional, when not provided the deaults are used.

{% icon 'icon_name' size=50 className="css classnames" %}


Todo
----

- Write tests

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-svg-icons-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

django_svg_icons-0.1.1-py2-none-any.whl (6.9 kB view details)

Uploaded Python 2

File details

Details for the file django-svg-icons-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django-svg-icons-0.1.1.tar.gz
Algorithm Hash digest
SHA256 05d0d3a461acf93ccb764344eda8ea2004b62ada43adc88a0eb83ec2ca85d505
MD5 2c80b30f72a1e8c263b2396ac22e5521
BLAKE2b-256 5111b28663a5d3dccdc73b97be93f3cc4906d5549b528df4df10812a1545d545

See more details on using hashes here.

File details

Details for the file django_svg_icons-0.1.1-py2-none-any.whl.

File metadata

File hashes

Hashes for django_svg_icons-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 292b671a7c1bdd9e79d4b09f91dc0679453bcf97d6e82ba068d87f3b1fb60faf
MD5 99c387df6b2b30de40479b800e5200f2
BLAKE2b-256 47c01ca9ddc82b4d54dd7a83a7828382b1bb09ec5f1dc660c12868f041133525

See more details on using hashes here.

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