Multi-library SVG icon system for Django - like react-icons, but backend-driven
Project description
djicons
Multi-library SVG icon system for Django. Like react-icons, but 100% backend-driven.
No CDN. No JavaScript. Offline-first.
Features
- Multi-library support: Ionicons, Heroicons, Material Symbols, Tabler, Lucide, Font Awesome
- SVG inline rendering: Full CSS control, no font loading, no HTTP requests
- Namespace system:
{% icon "ion:home" %},{% icon "hero:pencil" %} - LRU caching: Fast rendering with memory + optional Django cache
- Plugin system: Easy to add custom icon packs
- Django 4.2+ & 5.x: Fully compatible with modern Django
- 100% offline: All icons bundled, no external dependencies
Installation
pip install djicons
Add to INSTALLED_APPS:
INSTALLED_APPS = [
'djicons',
# ...
]
Download icon packs:
python -m djicons.scripts.download_icons
# Or download specific packs:
python -m djicons.scripts.download_icons ionicons heroicons
Quick Start
{% load djicons %}
{# Basic usage #}
{% icon "home" %}
{# With namespace (explicit library) #}
{% icon "ion:cart-outline" %}
{% icon "hero:pencil-square" %}
{% icon "material:shopping_cart" %}
{% icon "tabler:home" %}
{% icon "lucide:settings" %}
{% icon "fa:house" %}
{% icon "fa:github-brands" %}
{# With size #}
{% icon "ion:home" size=24 %}
{# With CSS classes #}
{% icon "hero:pencil" css_class="w-5 h-5 text-blue-500" %}
{# With color #}
{% icon "ion:heart" color="#ff0000" %}
{% icon "ion:heart" fill="currentColor" %}
{# With ARIA accessibility #}
{% icon "ion:menu" aria_label="Open menu" %}
{# With data attributes #}
{% icon "ion:close" data_action="dismiss" data_target="#modal" %}
{# Store in variable #}
{% icon "ion:home" as home_icon %}
{{ home_icon }}
Available Icon Packs
| Pack | Namespace | Icons | License |
|---|---|---|---|
| Ionicons | ion: |
~1,400 | MIT |
| Heroicons | hero: |
~300 | MIT |
| Material Symbols | material: |
~2,500 | Apache 2.0 |
| Tabler Icons | tabler: |
~5,000 | MIT |
| Lucide | lucide: |
~1,500 | ISC |
| Font Awesome Free | fa: |
~2,000 | CC BY 4.0 / MIT |
Total: ~12,700 icons
Font Awesome Styles
Font Awesome icons come in three styles:
{% icon "fa:house" %} {# solid (default) #}
{% icon "fa:heart-regular" %} {# regular/outlined #}
{% icon "fa:github-brands" %} {# brand logos #}
Note: Font Awesome Free requires attribution. See fontawesome.com/license
Configuration
# settings.py
DJICONS = {
# Default namespace for unqualified names
'DEFAULT_NAMESPACE': 'ion',
# Icon packs to load
'PACKS': ['ionicons', 'heroicons', 'material', 'tabler', 'lucide', 'fontawesome'],
# Return empty string for missing icons (vs raising error)
'MISSING_ICON_SILENT': True,
# Use Django cache backend
'USE_DJANGO_CACHE': False,
# Cache timeout in seconds
'CACHE_TIMEOUT': 86400,
# Max icons in memory cache
'MEMORY_CACHE_SIZE': 1000,
# Default CSS class for all icons
'DEFAULT_CLASS': '',
# Add aria-hidden by default
'ARIA_HIDDEN': True,
# Semantic aliases
'ALIASES': {
'edit': 'hero:pencil',
'delete': 'hero:trash',
'add': 'ion:add-outline',
},
}
Programmatic Usage
from djicons import icons, Icon, get, register
from djicons.loaders import DirectoryIconLoader
# Get an icon
icon = icons.get("ion:home")
html = icon.render(size=24, css_class="text-primary")
# Shortcut function
html = get("ion:home", size=24)
# Register custom icon
icons.register("my-icon", "<svg>...</svg>", namespace="myapp")
# Register a directory of icons
loader = DirectoryIconLoader("/path/to/icons")
icons.register_loader(loader, namespace="custom")
# Create aliases
icons.register_alias("edit", "hero:pencil")
# List icons
all_icons = icons.list_icons()
ion_icons = icons.list_icons("ion")
namespaces = icons.list_namespaces()
Icon Class API
from djicons import Icon
icon = Icon(
name="home",
svg_content="<svg>...</svg>",
namespace="myapp",
category="navigation",
tags=["house", "main"],
)
# Render with options
html = icon.render(
size=24, # width & height
width=24, # or separate
height=24,
css_class="icon", # CSS classes
color="#000", # CSS color
fill="currentColor", # SVG fill
stroke="#000", # SVG stroke
aria_label="Home", # Accessibility
aria_hidden=True, # Hide from screen readers
data_action="click", # data-* attributes
)
ERPlora Integration
For ERPlora modules:
# In your module's apps.py
from django.apps import AppConfig
class InventoryConfig(AppConfig):
name = 'inventory'
def ready(self):
from djicons.contrib.erplora import register_module_icons
register_module_icons(self.name, self.path)
Or auto-discover all modules:
# In Django settings or ready()
from djicons.contrib.erplora import discover_module_icons
discover_module_icons("/path/to/modules")
Then use in templates:
{% icon "inventory:box" %}
{% icon "sales:receipt" %}
Template Tags Reference
{% icon %}
Render an SVG icon inline.
{% icon name [size=N] [width=N] [height=N] [css_class="..."] [color="..."] [fill="..."] [stroke="..."] [aria_label="..."] [aria_hidden=True|False] [**attrs] %}
{% icon_exists %}
Check if an icon exists.
{% icon_exists "ion:home" as has_home %}
{% if has_home %}...{% endif %}
{% icon_list %}
List available icons.
{% icon_list "ion" as ionicons %}
{% for name in ionicons %}
{% icon name size=24 %}
{% endfor %}
{% icon_sprite %}
Render SVG sprite sheet (for advanced use).
{% icon_sprite "ion" %}
Development
# Clone repository
git clone https://github.com/djicons/djicons.git
cd djicons
# Install dependencies
pip install -e ".[dev]"
# Download icon packs
python scripts/download_icons.py
# Run tests
pytest
# Run linting
ruff check .
ruff format .
License
MIT License - see LICENSE for details.
Icon packs are distributed under their respective licenses:
- Ionicons: MIT
- Heroicons: MIT
- Material Symbols: Apache 2.0
- Tabler Icons: MIT
- Lucide: ISC
- Font Awesome Free: CC BY 4.0 (icons) / MIT (code)
Credits
- Inspired by react-icons
- Built for ERPlora modular ERP system
- Created by Ioan Beilic
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djicons-0.1.0.tar.gz.
File metadata
- Download URL: djicons-0.1.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eff3345eff0fd3bb308dad6756ce48da657ab1ba87bed8cbb04d84e21e1d02d
|
|
| MD5 |
cfe571e42336bbc469132cf8f92c42d3
|
|
| BLAKE2b-256 |
42f5395b8293f0d8323d4d1d887119863e4785391e7cc02ae13724778c4136c1
|
Provenance
The following attestation bundles were made for djicons-0.1.0.tar.gz:
Publisher:
publish.yml on ioanbeilic/djicons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djicons-0.1.0.tar.gz -
Subject digest:
9eff3345eff0fd3bb308dad6756ce48da657ab1ba87bed8cbb04d84e21e1d02d - Sigstore transparency entry: 789867987
- Sigstore integration time:
-
Permalink:
ioanbeilic/djicons@682bf446599c8a90ce23d30a3c35e0910dfafd48 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/ioanbeilic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@682bf446599c8a90ce23d30a3c35e0910dfafd48 -
Trigger Event:
release
-
Statement type:
File details
Details for the file djicons-0.1.0-py3-none-any.whl.
File metadata
- Download URL: djicons-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c1f8048011d0be10823525a63a0b08ef48526f294a580e424d1d51b6e9ed021
|
|
| MD5 |
3a5f884273098cf58c61ce76d0c2ac66
|
|
| BLAKE2b-256 |
e298e6c82dcf63bfc89b2acf5499af3d8d4f41202ce06ff406d17df674b4236e
|
Provenance
The following attestation bundles were made for djicons-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ioanbeilic/djicons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djicons-0.1.0-py3-none-any.whl -
Subject digest:
0c1f8048011d0be10823525a63a0b08ef48526f294a580e424d1d51b6e9ed021 - Sigstore transparency entry: 789867993
- Sigstore integration time:
-
Permalink:
ioanbeilic/djicons@682bf446599c8a90ce23d30a3c35e0910dfafd48 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/ioanbeilic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@682bf446599c8a90ce23d30a3c35e0910dfafd48 -
Trigger Event:
release
-
Statement type: