CSS-only icon system for Django
Project description
django-iconx
CSS-only icon system for Django.
Generates a single CSS file from SVG icon sources (e.g. Lucide, Heroicons, or your own SVGs). Icons are rendered purely via CSS — no JavaScript, no icon fonts, no template tags needed.
Usage
<!-- basic icon -->
<i class="icon icon-search" aria-hidden="true"></i>
<!-- sized via Tailwind text-* (width/height = 1em, so font-size controls size) -->
<i class="icon icon-check text-2xl" aria-hidden="true"></i>
<!-- colored via Tailwind text-* (mono icons only, via currentColor mask trick) -->
<i class="icon icon-check text-2xl text-green-500" aria-hidden="true"></i>
<!-- multi-color icon (preserves original SVG colors) -->
<i class="icon icon-logo text-4xl" aria-hidden="true"></i>
How it works
Mono icons use mask-image + background-color: currentColor — the SVG acts as a mask, so the icon inherits text color. Multi-color icons use background-image to render the SVG as-is.
/* base: all icons */
.icon { display: inline-block; width: 1em; height: 1em; }
/* mono icons: grouped selector */
.icon-search, .icon-check, ... {
background-color: currentColor;
mask-size: contain;
mask-repeat: no-repeat;
mask-position: center;
mask-mode: alpha;
}
/* individual mask per icon */
.icon-search { mask-image: url("/static/icons/search.svg"); }
/* multi-color icons: grouped selector */
.icon-logo, .icon-badge, ... {
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
.icon-logo { background-image: url("/static/logos/logo.svg"); }
Key design choices:
currentColor— mono icons inherit text color automatically1emsizing — icons scale with font size via Tailwindtext-*classesmask-mode: alpha— SVG alpha channel drives the mask, fill colors are irrelevant- Direct element styling — no
::beforepseudo-element, simpler CSS - Tree-shakeable — PurgeCSS strips unused
.icon-*rules from the generated CSS
Browser support
django-iconx uses CSS mask-image, which is supported unprefixed in all modern browsers since December 2023 (~97% global coverage). Older browsers (Chrome < 120, Safari < 15.4) need the -webkit-mask-image prefix.
Tailwind v4 handles vendor prefixing automatically — just @import the generated CSS file in your Tailwind entry point:
@import "tailwindcss";
@import "./static/iconx/icons.css";
With vendor prefixes applied, the only unsupported browsers are pre-Chromium Edge (≤ 18) and Internet Explorer.
Installation
pip install django-iconx
Documentation
Full documentation at oliverhaas.github.io/django-iconx
License
MIT
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_iconx-0.1.0a2.tar.gz.
File metadata
- Download URL: django_iconx-0.1.0a2.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
148a4e1d329cf4c7ff8692799a17dc29dda25430dc476f7f8cab0765adcdf0ec
|
|
| MD5 |
7f987ad162801f5e446ec87c5e73162e
|
|
| BLAKE2b-256 |
18c33d3244ecb723d39f29a7571d0c4f8c8c31a0a4022fb7b1db1b87ca20852f
|
Provenance
The following attestation bundles were made for django_iconx-0.1.0a2.tar.gz:
Publisher:
publish.yml on oliverhaas/django-iconx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_iconx-0.1.0a2.tar.gz -
Subject digest:
148a4e1d329cf4c7ff8692799a17dc29dda25430dc476f7f8cab0765adcdf0ec - Sigstore transparency entry: 1243647069
- Sigstore integration time:
-
Permalink:
oliverhaas/django-iconx@4b6c8e015d19eb71764cf8b6b91e4cb4f71ba95a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4b6c8e015d19eb71764cf8b6b91e4cb4f71ba95a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_iconx-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: django_iconx-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 11.7 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 |
45cb9f1c1146325995523c68f3b1cf05925699e5cb59b19d85ff717c75bf01d0
|
|
| MD5 |
21d3b28b8b3472e56914cb2516d537f0
|
|
| BLAKE2b-256 |
bd7e5bf2812a780985a209f1bb656c61bea0f360262716127f7f12d891151c81
|
Provenance
The following attestation bundles were made for django_iconx-0.1.0a2-py3-none-any.whl:
Publisher:
publish.yml on oliverhaas/django-iconx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_iconx-0.1.0a2-py3-none-any.whl -
Subject digest:
45cb9f1c1146325995523c68f3b1cf05925699e5cb59b19d85ff717c75bf01d0 - Sigstore transparency entry: 1243647085
- Sigstore integration time:
-
Permalink:
oliverhaas/django-iconx@4b6c8e015d19eb71764cf8b6b91e4cb4f71ba95a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oliverhaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4b6c8e015d19eb71764cf8b6b91e4cb4f71ba95a -
Trigger Event:
workflow_dispatch
-
Statement type: