Skip to main content

CSS-only icon system for Django

Project description

django-iconx

PyPI version Python versions CI

CSS-only icon system for Django.

django-iconx demo

Generates a single CSS file from SVG icon sources (Lucide, Heroicons, or your own). No JavaScript, no icon fonts.

<i class="icon icon-search"></i>
<span class="icon icon-check text-2xl text-green-500"></span>
<!-- aria-hidden="true" hides decorative icons from screen readers -->
<i class="icon icon-search" aria-hidden="true"></i>

How it works and what the upsides are

Mono icons use mask-image with background-color: currentColor, so the SVG acts as a mask and the icon inherits text color. Multi-color icons use background-image to preserve original SVG colors.

The output is plain CSS classes: no runtime, no bundler plugin, no framework coupling. The approach is not Django-specific; Django is just a good fit because its static file conventions make wiring it up easy. Any stack that serves CSS and renders HTML can use the generated stylesheet directly.

.icon { display: inline-block; width: 1em; height: 1em; }

.icon-search, .icon-check { background-color: currentColor; mask-size: contain; mask-mode: alpha; }
.icon-search { mask-image: url("/static/icons/search.svg"); }

.icon-logo { background-image: url("/static/logos/logo.svg"); }
  • currentColor + mask-image: icons inherit text color
  • 1em sizing: icons scale with font size / Tailwind text-*
  • Direct element styling, no ::before pseudo-element
  • Tree-shakeable: PurgeCSS strips unused .icon-* rules

Browser support

CSS mask-image is supported unprefixed in all modern browsers since Dec 2023 (~97% global coverage). Tailwind v4 handles vendor prefixing automatically:

@import "tailwindcss";
@import "./static/iconx/icons.css";

Installation

uv add django-iconx

Full documentation at oliverhaas.github.io/django-iconx

License

MIT

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_iconx-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_iconx-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file django_iconx-0.1.0.tar.gz.

File metadata

  • Download URL: django_iconx-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_iconx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc83f44cdc22502405e6be453ff282e69c9d418656bb76dc11ad280a76a27d32
MD5 260a7de8da8102d0a4cea0be3e8e4e13
BLAKE2b-256 bb23a93661a4120bd1488aebc0ae4422e8c505afe03f9e132948e6b97526dc9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_iconx-0.1.0.tar.gz:

Publisher: publish.yml on oliverhaas/django-iconx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_iconx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_iconx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_iconx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af4da5ef6fbc220530481bd2fe421910ae5f66db174618e73f518650324b4f3a
MD5 dad68008aa2a71f70569ca9db6b508ec
BLAKE2b-256 e2705e25c6265302a950e9aa148b4186ece5de868a90cf940f6d916c961c0c4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_iconx-0.1.0-py3-none-any.whl:

Publisher: publish.yml on oliverhaas/django-iconx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page