Use Simple Icons brand icons in your Django and Jinja templates.
Project description
django-simple-icons
Use Simple Icons, 3,449 SVG brand icons, in your Django and Jinja templates. The icons ship inside the package, so there is no CDN to call and no static files to collect. Each icon renders as inline SVG that follows the surrounding text color.
Installation
Install with the extra matching your template engine:
python -m pip install 'django-simple-icons[django]'
python -m pip install 'django-simple-icons[jinja]'
The package itself has no runtime dependencies and needs Python 3.12 or later.
Django
Add the app to INSTALLED_APPS so the template tag library can be loaded:
INSTALLED_APPS = [
...,
"django_simple_icons",
]
Then load the library and render an icon by its slug:
{% load simple_icons %}
{% simple_icon "django" %}
That produces a 24x24 inline SVG which inherits the current text color and is hidden from screen readers:
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" aria-hidden="true"><path d="M11.146 0h3.924…"/></svg>
Sizing
size sets both width and height and defaults to 24:
{% simple_icon "django" size=48 %}
Pass size=None to omit both attributes, which is what you want when CSS classes
control the size:
{% simple_icon "django" size=None class="h-6 w-6" %}
Color
Icons use fill="currentColor" by default, so they follow the surrounding text. Pass
color="brand" to use the brand's official color, or any CSS color to set it directly:
{% simple_icon "django" color="brand" %}
{% simple_icon "django" color="#ff6600" %}
Extra attributes
Any other keyword argument becomes an attribute on the <svg> element, with
underscores converted to dashes:
{% simple_icon "django" class="h-6 w-6 text-green-700" data_controller="icon" %}
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" aria-hidden="true" class="h-6 w-6 text-green-700" data-controller="icon"><path d="M11.146 0h3.924…"/></svg>
Values are escaped, so data_test="a < 2" renders as data-test="a < 2".
Accessibility
Icons are decorative by default, so the upstream <title> is removed and
aria-hidden="true" is set. An icon next to a text label needs nothing more.
For a standalone icon that carries meaning, pass title=True to keep the brand name as
the accessible name, or pass a string to replace it:
{% simple_icon "django" title=True %}
{% simple_icon "django" title="Django framework" %}
Either form keeps role="img" and drops aria-hidden:
<svg role="img" viewBox="0 0 24 24" width="24" height="24" fill="currentColor"><title>Django framework</title><path d="M11.146 0h3.924…"/></svg>
Jinja
Register the function as a global on your environment:
from django_simple_icons.jinja import simple_icon
environment.globals["simple_icon"] = simple_icon
Call it with the same arguments as the Django tag:
{{ simple_icon("django") }}
{{ simple_icon("django", size=48, color="brand") }}
{{ simple_icon("django", title="Django framework") }}
The result is a markupsafe.Markup, so it renders unescaped under autoescaping.
Because class is a reserved word in Python, spell it class_ when calling the
function directly. The trailing underscore is stripped:
{{ simple_icon("django", class_="h-6 w-6") }}
Arguments
| Argument | Default | Description |
|---|---|---|
name |
required | The icon slug, such as "django" |
size |
24 |
Sets width and height; None omits both |
color |
"currentColor" |
Any CSS color, or "brand" for the brand's official color |
title |
False |
True keeps the brand name, a string replaces it |
**attrs |
none | Extra attributes; underscores become dashes |
Brand colors
get_brand_color returns a brand's official color, which is useful outside a template:
>>> from django_simple_icons import get_brand_color
>>> get_brand_color("django")
'#092E20'
Finding icon slugs
Slugs match the names on simpleicons.org, where you can
search the full set. An unknown slug raises IconDoesNotExist with suggestions:
>>> from django_simple_icons import get_brand_color
>>> get_brand_color("djngo")
Traceback (most recent call last):
...
django_simple_icons.IconDoesNotExist: Icon 'djngo' does not exist. Did you mean: django, deno, fandango? Browse the available icons at https://simpleicons.org/
Supported versions
- Python 3.12, 3.13 and 3.14
- Django 5.2, 6.0 and 6.1 are tested. Django is declared as
>=4.2because the code uses nothing newer, but only the tested versions are supported. - Jinja2 2.8 and later
Versioning
The package version mirrors the bundled Simple Icons release, so version 16.26.0 contains Simple Icons 16.26.0. A fix to this package that ships no new icons appends a fourth segment, such as 16.26.0.1.
License
The code in this package is MIT licensed. The icons come from Simple Icons and are CC0-1.0.
Brand icons and names are trademarks of their respective owners. Using an icon does not imply endorsement, and some brands restrict how their marks may be used. Read the Simple Icons legal disclaimer before shipping an icon.
Project details
Release history Release notifications | RSS feed
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 django_simple_icons-16.27.0.tar.gz.
File metadata
- Download URL: django_simple_icons-16.27.0.tar.gz
- Upload date:
- Size: 2.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60ac4badf732e3df142031d4eea734d72e8b9413e1b99d6938076044f191d3b6
|
|
| MD5 |
cebb23992af696fe540bd56701e5a54f
|
|
| BLAKE2b-256 |
65305d875c6f776b224008897d73854167a23017c3bf084c54011af17f97d485
|
Provenance
The following attestation bundles were made for django_simple_icons-16.27.0.tar.gz:
Publisher:
main.yml on M4p4/django-simple-icons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_simple_icons-16.27.0.tar.gz -
Subject digest:
60ac4badf732e3df142031d4eea734d72e8b9413e1b99d6938076044f191d3b6 - Sigstore transparency entry: 2198098464
- Sigstore integration time:
-
Permalink:
M4p4/django-simple-icons@4f0c00217036c1a060cf82133875d1a126cb0cc6 -
Branch / Tag:
refs/tags/16.27.0 - Owner: https://github.com/M4p4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@4f0c00217036c1a060cf82133875d1a126cb0cc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_simple_icons-16.27.0-py3-none-any.whl.
File metadata
- Download URL: django_simple_icons-16.27.0-py3-none-any.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de62b4a99754068fef4014391a3b39b8eb6eeff51595547f7d69994c17ce27c3
|
|
| MD5 |
af8550933e64d343078c524cdb9186e1
|
|
| BLAKE2b-256 |
f785e06a6eef5352c0f8117e89997176594d75fe35f25444b370035e43b3b7c9
|
Provenance
The following attestation bundles were made for django_simple_icons-16.27.0-py3-none-any.whl:
Publisher:
main.yml on M4p4/django-simple-icons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_simple_icons-16.27.0-py3-none-any.whl -
Subject digest:
de62b4a99754068fef4014391a3b39b8eb6eeff51595547f7d69994c17ce27c3 - Sigstore transparency entry: 2198098570
- Sigstore integration time:
-
Permalink:
M4p4/django-simple-icons@4f0c00217036c1a060cf82133875d1a126cb0cc6 -
Branch / Tag:
refs/tags/16.27.0 - Owner: https://github.com/M4p4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@4f0c00217036c1a060cf82133875d1a126cb0cc6 -
Trigger Event:
push
-
Statement type: