dj-lucide


Namedj-lucide JSON
Version 1.1.8 PyPI version JSON
download
home_pageNone
SummaryUse lucide in your Django and Jinja templates.
upload_time2025-08-01 07:34:34
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dj-lucide
<a href="https://github.com/vidski/lucide/actions?workflow=CI">
    <img
        src="https://img.shields.io/github/actions/workflow/status/franciscobmacedo/lucide/main.yml.svg?branch=main&style=for-the-badge"
        alt="CI"
        style="max-width: 100%;"
    >
</a>
<a href="https://pypi.org/project/dj-lucide/">
    <img
        src="https://img.shields.io/pypi/v/dj-lucide.svg?style=for-the-badge"
        alt="pypi"
        style="max-width: 100%;"
    >
</a>
<a href="https://github.com/psf/black">
    <img
        src="https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge"
        alt="black"
        style="max-width: 100%;"
    >
</a>
<a href="https://github.com/pre-commit/pre-commit">
    <img
        src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge"
        alt="pre-commit"
        style="max-width: 100%;"
    >
</a>


Use [lucide icons](https://lucide.dev/) in your Django and Jinja templates.

## Requirements

Python 3.8 to 3.12 supported.

Django 3.2 to 5.0 supported.

## Usage

The `dj-lucide` package supports both Django templates and Jinja templates.
Follow the appropriate guide below.

### Django templates

1.  Install with `python -m pip install dj-lucide[django]`.

2.  Add to your `INSTALLED_APPS`:

    ```python
    INSTALLED_APPS = [
        ...,
        "lucide",
        ...,
    ]
    ```

3. Now your templates can load the template library with:

    ```django
        {% load lucide %}
    ```

Alternatively, make the library available in all templates by adding it to [the builtins option](https://docs.djangoproject.com/en/stable/topics/templates/#django.template.backends.django.DjangoTemplates>):

```python
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        # ...
        "OPTIONS": {
            # ...
            "builtins": [
                ...,
                "lucide.templatetags.lucide",
                ...,
            ],
        },
    }
]
```

The library provides one tag (`lucide`) to render SVG icons which can take these arguments:

- `name`, positional: the name of the icon to use. You can see the icon names on the [lucide grid](https://lucide.dev/icons/).

- `size`, keyword: an integer that will be used for the width and height attributes of the output `<svg>` tag.
  Defaults to the icons’ designed sizes, `24`.
  It can also be `None`, in which case no width or height attributes will be output.

- Any number of keyword arguments.
  These will be added as attributes in the output HTML.
  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. `data-` attributes.


Most attributes will be added to the `<svg>` tag containing the icon, but these attributes will be attached to the inner `<path>` tags instead:

  - `stroke-linecap`
  - `stroke-linejoin`
  - `vector-effect`

> Note: unlike the SVG code you can copy from [lucide grid](https://lucide.dev/icons/), there is no default `class`.

#### Examples

An "a-arrow-down” icon:

```django
    {% lucide "a-arrow-down" %}
```

The same icon at 40x40 pixels, and a CSS class:

```django
    {% lucide "a-arrow-down" size=40 class="mr-4" %}
```

That icon again, but with the paths changed to a narrower stroke width, and a "data-controller" attribute declared:

```django
    {% lucide "a-arrow-down" stroke_width=1 data_controller="language" %}
```

### Jinja templates

1. Install with `python -m pip install lucide[jinja]`.

2. Adjust your Jinja `Environment` to add the global `lucide` function from `lucide.jinja`.
   For example:

   ```python
       from lucide.jinja import lucide
       from jinja2 import Environment

       env = Environment()
       env.globals.update({
               "lucide": lucide
           }
       )
    ```
3. Now in your templates you can call that function, which will render the corresponding `<svg>` icons. The function takes these arguments:

- `name`, positional: the name of the icon to use.
  You can see the icon names on the [lucide grid](https://lucide.dev/icons/)

- `size`, keyword: an integer that will be used for the width and height attributes of the output `<svg>` tag.
  Defaults to the icons’ designed sizes, `24`.
  Can be `None`, in which case no width or height attributes will be output.

- Any number of keyword arguments.
  These will be added as HTML attributes to the output HTML.
  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. `data-` attributes.

Most attributes will be added to the `<svg>` tag containing the icon, but these attributes will be attached to the inner `<path>` tags instead:

  - `stroke-linecap`
  - `stroke-linejoin`
  - `vector-effect`

> Note: unlike the SVG code you can copy from [lucide grid](https://lucide.dev/icons/), there is no default `class`.

#### Examples

An "a-arrow-down” icon:

```jinja
    {{ lucide("a-arrow-down") }}
```

The same icon at 40x40 pixels and a CSS class:

```jinja
    {{ lucide("a-arrow-down", size=40, class="mr-4") }}
```

That icon again, but with the paths changed to a narrower stroke width, and a "data-controller" attribute declared:

```jinja
    {{ lucide("a-arrow-down", stroke_width=1, data_controller="language") }}
```

### Use the Latest Lucide Icons (Custom Update & ZIP Selection)

By default, this package uses the Lucide icon ZIP file bundled within the package.
**You can now easily update to the latest Lucide icons at any time—without waiting for a package release.**

**Updating to the Latest Icons**

A management command is provided to fetch the newest icons and save them to your project’s root folder.

**Usage:**

```bash
python manage.py update_lucide_icons
```
This will download the latest Lucide icon ZIP from GitHub and save it as lucide-latest.zip in your Django project’s root directory.

## Using a Custom ZIP File (Settings Option)
You can explicitly tell lucide which ZIP file to use by setting the following variable in your settings.py:
```python
import os
LUCIDE_ICONS_ZIP_PATH = os.path.join(BASE_DIR, "lucide-latest.zip")
```
If this setting is provided and the file exists, lucide will always load icons from your specified ZIP file.

If the file is missing or the setting is unset, lucide falls back to the built-in package ZIP.

## Acknowledgements

This package is heavely inspired by [Adam Johnson's heroicons](https://github.com/adamchainz/heroicons). It's actually mostly copied from it so a huge thanks Adam!
This package is forked from [Francisco Macedo's lucide](https://github.com/franciscobmacedo/lucide).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dj-lucide",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "Django",
    "author": null,
    "author_email": "David Rydwanski <dr@squies.de>, Francisco Macedo <me@fmacedo.com>",
    "download_url": "https://files.pythonhosted.org/packages/71/eb/0ff4063fbd91e97a8d2e6996bcf2dde765e21286a7810245084bba01866e/dj_lucide-1.1.8.tar.gz",
    "platform": null,
    "description": "# dj-lucide\n<a href=\"https://github.com/vidski/lucide/actions?workflow=CI\">\n    <img\n        src=\"https://img.shields.io/github/actions/workflow/status/franciscobmacedo/lucide/main.yml.svg?branch=main&style=for-the-badge\"\n        alt=\"CI\"\n        style=\"max-width: 100%;\"\n    >\n</a>\n<a href=\"https://pypi.org/project/dj-lucide/\">\n    <img\n        src=\"https://img.shields.io/pypi/v/dj-lucide.svg?style=for-the-badge\"\n        alt=\"pypi\"\n        style=\"max-width: 100%;\"\n    >\n</a>\n<a href=\"https://github.com/psf/black\">\n    <img\n        src=\"https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge\"\n        alt=\"black\"\n        style=\"max-width: 100%;\"\n    >\n</a>\n<a href=\"https://github.com/pre-commit/pre-commit\">\n    <img\n        src=\"https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge\"\n        alt=\"pre-commit\"\n        style=\"max-width: 100%;\"\n    >\n</a>\n\n\nUse [lucide icons](https://lucide.dev/) in your Django and Jinja templates.\n\n## Requirements\n\nPython 3.8 to 3.12 supported.\n\nDjango 3.2 to 5.0 supported.\n\n## Usage\n\nThe `dj-lucide` package supports both Django templates and Jinja templates.\nFollow the appropriate guide below.\n\n### Django templates\n\n1.  Install with `python -m pip install dj-lucide[django]`.\n\n2.  Add to your `INSTALLED_APPS`:\n\n    ```python\n    INSTALLED_APPS = [\n        ...,\n        \"lucide\",\n        ...,\n    ]\n    ```\n\n3. Now your templates can load the template library with:\n\n    ```django\n        {% load lucide %}\n    ```\n\nAlternatively, make the library available in all templates by adding it to [the builtins option](https://docs.djangoproject.com/en/stable/topics/templates/#django.template.backends.django.DjangoTemplates>):\n\n```python\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        # ...\n        \"OPTIONS\": {\n            # ...\n            \"builtins\": [\n                ...,\n                \"lucide.templatetags.lucide\",\n                ...,\n            ],\n        },\n    }\n]\n```\n\nThe library provides one tag (`lucide`) to render SVG icons which can take these arguments:\n\n- `name`, positional: the name of the icon to use. You can see the icon names on the [lucide grid](https://lucide.dev/icons/).\n\n- `size`, keyword: an integer that will be used for the width and height attributes of the output `<svg>` tag.\n  Defaults to the icons\u2019 designed sizes, `24`.\n  It can also be `None`, in which case no width or height attributes will be output.\n\n- Any number of keyword arguments.\n  These will be added as attributes in the output HTML.\n  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. `data-` attributes.\n\n\nMost attributes will be added to the `<svg>` tag containing the icon, but these attributes will be attached to the inner `<path>` tags instead:\n\n  - `stroke-linecap`\n  - `stroke-linejoin`\n  - `vector-effect`\n\n> Note: unlike the SVG code you can copy from [lucide grid](https://lucide.dev/icons/), there is no default `class`.\n\n#### Examples\n\nAn \"a-arrow-down\u201d icon:\n\n```django\n    {% lucide \"a-arrow-down\" %}\n```\n\nThe same icon at 40x40 pixels, and a CSS class:\n\n```django\n    {% lucide \"a-arrow-down\" size=40 class=\"mr-4\" %}\n```\n\nThat icon again, but with the paths changed to a narrower stroke width, and a \"data-controller\" attribute declared:\n\n```django\n    {% lucide \"a-arrow-down\" stroke_width=1 data_controller=\"language\" %}\n```\n\n### Jinja templates\n\n1. Install with `python -m pip install lucide[jinja]`.\n\n2. Adjust your Jinja `Environment` to add the global `lucide` function from `lucide.jinja`.\n   For example:\n\n   ```python\n       from lucide.jinja import lucide\n       from jinja2 import Environment\n\n       env = Environment()\n       env.globals.update({\n               \"lucide\": lucide\n           }\n       )\n    ```\n3. Now in your templates you can call that function, which will render the corresponding `<svg>` icons. The function takes these arguments:\n\n- `name`, positional: the name of the icon to use.\n  You can see the icon names on the [lucide grid](https://lucide.dev/icons/)\n\n- `size`, keyword: an integer that will be used for the width and height attributes of the output `<svg>` tag.\n  Defaults to the icons\u2019 designed sizes, `24`.\n  Can be `None`, in which case no width or height attributes will be output.\n\n- Any number of keyword arguments.\n  These will be added as HTML attributes to the output HTML.\n  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. `data-` attributes.\n\nMost attributes will be added to the `<svg>` tag containing the icon, but these attributes will be attached to the inner `<path>` tags instead:\n\n  - `stroke-linecap`\n  - `stroke-linejoin`\n  - `vector-effect`\n\n> Note: unlike the SVG code you can copy from [lucide grid](https://lucide.dev/icons/), there is no default `class`.\n\n#### Examples\n\nAn \"a-arrow-down\u201d icon:\n\n```jinja\n    {{ lucide(\"a-arrow-down\") }}\n```\n\nThe same icon at 40x40 pixels and a CSS class:\n\n```jinja\n    {{ lucide(\"a-arrow-down\", size=40, class=\"mr-4\") }}\n```\n\nThat icon again, but with the paths changed to a narrower stroke width, and a \"data-controller\" attribute declared:\n\n```jinja\n    {{ lucide(\"a-arrow-down\", stroke_width=1, data_controller=\"language\") }}\n```\n\n### Use the Latest Lucide Icons (Custom Update & ZIP Selection)\n\nBy default, this package uses the Lucide icon ZIP file bundled within the package.\n**You can now easily update to the latest Lucide icons at any time\u2014without waiting for a package release.**\n\n**Updating to the Latest Icons**\n\nA management command is provided to fetch the newest icons and save them to your project\u2019s root folder.\n\n**Usage:**\n\n```bash\npython manage.py update_lucide_icons\n```\nThis will download the latest Lucide icon ZIP from GitHub and save it as lucide-latest.zip in your Django project\u2019s root directory.\n\n## Using a Custom ZIP File (Settings Option)\nYou can explicitly tell lucide which ZIP file to use by setting the following variable in your settings.py:\n```python\nimport os\nLUCIDE_ICONS_ZIP_PATH = os.path.join(BASE_DIR, \"lucide-latest.zip\")\n```\nIf this setting is provided and the file exists, lucide will always load icons from your specified ZIP file.\n\nIf the file is missing or the setting is unset, lucide falls back to the built-in package ZIP.\n\n## Acknowledgements\n\nThis package is heavely inspired by [Adam Johnson's heroicons](https://github.com/adamchainz/heroicons). It's actually mostly copied from it so a huge thanks Adam!\nThis package is forked from [Francisco Macedo's lucide](https://github.com/franciscobmacedo/lucide).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Use lucide in your Django and Jinja templates.",
    "version": "1.1.8",
    "project_urls": {
        "Changelog": "https://github.com/vidski/lucide/blob/main/CHANGELOG.md",
        "Repository": "https://github.com/vidski/lucide"
    },
    "split_keywords": [
        "django"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "80d6921029691469cc2d36e93e56ebe47c302d54915926745f4ca07589d6a107",
                "md5": "1fcd8883114130eaa4d13c3ee8974bdd",
                "sha256": "e0755c58d050a91b0561d29bbe73f1d75fab04f9ba393f3b78e1169d8b46924a"
            },
            "downloads": -1,
            "filename": "dj_lucide-1.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1fcd8883114130eaa4d13c3ee8974bdd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 404712,
            "upload_time": "2025-08-01T07:34:26",
            "upload_time_iso_8601": "2025-08-01T07:34:26.141225Z",
            "url": "https://files.pythonhosted.org/packages/80/d6/921029691469cc2d36e93e56ebe47c302d54915926745f4ca07589d6a107/dj_lucide-1.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "71eb0ff4063fbd91e97a8d2e6996bcf2dde765e21286a7810245084bba01866e",
                "md5": "35c6bcc203e853084c1349b6bcf3e930",
                "sha256": "98d3dde08ef54a1c76f9f85113e07d05f3e93a4d8f8044d1be2e2548937ab030"
            },
            "downloads": -1,
            "filename": "dj_lucide-1.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "35c6bcc203e853084c1349b6bcf3e930",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 404542,
            "upload_time": "2025-08-01T07:34:34",
            "upload_time_iso_8601": "2025-08-01T07:34:34.780536Z",
            "url": "https://files.pythonhosted.org/packages/71/eb/0ff4063fbd91e97a8d2e6996bcf2dde765e21286a7810245084bba01866e/dj_lucide-1.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-01 07:34:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vidski",
    "github_project": "lucide",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "dj-lucide"
}
        
Elapsed time: 0.71664s