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. No JavaScript, no icon fonts.

python manage.py iconx add lucide
<i class="icon icon-search"></i>
<span class="icon icon-check text-2xl text-green-500"></span>

Built-in support for Lucide, Heroicons, Tabler, Phosphor, Bootstrap Icons, and Remix. Or bring your own SVGs.

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";

Quick start

uv add django-iconx
INSTALLED_APPS = ["django_iconx", ...]
STATICFILES_DIRS = [BASE_DIR / "static"]
python manage.py iconx add lucide

That downloads Lucide icons and generates the CSS. Include the CSS in your template or Tailwind entry point and use icons via class names. See the full documentation at oliverhaas.github.io/django-iconx for custom SVGs, multiple icon sets, and configuration options.

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.2.0.tar.gz (11.2 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.2.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_iconx-0.2.0.tar.gz
  • Upload date:
  • Size: 11.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 91c0c44c0d501a4cf00ae093085b4611e8b92d98f002ce39986cf74a4d0b68af
MD5 2f442f8930f8ef314156bcb8870e6c4c
BLAKE2b-256 d2e18c0e96247274c59e9dc2575c0d6c9cb472ec5f30faa7c192b4aebba68c9d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: django_iconx-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72c39bf66925d30ce4710c84e7134fa2e63aa2bf76d3b130915de1b9e7a2e72e
MD5 1a10e164c36d9279d1335eaf40e22a26
BLAKE2b-256 f062ef7b6cfdaabfdebf509e95998dcef5e33d98c0a58cd967846bc4cf1ff617

See more details on using hashes here.

Provenance

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