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 -- 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.0a3.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.0a3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for django_iconx-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 b0c006f6ca24d160e87180ec6f6f2bab0c31c3874bb100f4ea86bc8ee7610a09
MD5 830f2a1a74d09603bbe031820af3e31e
BLAKE2b-256 811cb482d03c6c0b2d02d0a95bc7a19fcfba131e885ebcd71590d426b8d0cbd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_iconx-0.1.0a3.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.0a3-py3-none-any.whl.

File metadata

  • Download URL: django_iconx-0.1.0a3-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.7

File hashes

Hashes for django_iconx-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 e3fe02a04237cddb576195174520ad1070c5b290b3f958feb64f96844adae7bf
MD5 32c4c36912e8ad5e9cb4f459a06c7790
BLAKE2b-256 89ebaa50855e71306c999c32f9e0f75e87dfa93505a3961a9fc6d0cfcae4ef0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_iconx-0.1.0a3-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