Use Tabler Icons in your Django and Jinja templates.
Project description
tablericons
Use Tabler Icons in your Django and Jinja templates.
Requirements
Python from 3.10 supported.
Django from 5.2 supported.
Usage
The tablericons2 package supports both Django templates and Jinja templates.
Follow the appropriate guide below.
Django templates
-
Install with
python -m pip install tablericons2[django]. -
Add to your
INSTALLED_APPS:INSTALLED_APPS = [ ..., "tablericons", ..., ]
-
Now your templates can load the template library with:
{% load tablericons %}
Alternatively, make the library available in all templates by adding it to the builtins option:
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
# ...
"OPTIONS": {
# ...
"builtins": [
...,
"tablericons.templatetags.tablericons",
...,
],
},
}
]
The library provides one tag (icon) 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 tabler grid. -
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 beNone, 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-linecapstroke-linejoinvector-effect
Note: unlike the SVG code you can copy from tabler grid, there is no default
class.
Examples
An "a-arrow-down” icon:
{% icon "a-arrow-down" %}
The same icon at 40x40 pixels, and a CSS class:
{% icon "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:
{% icon "a-arrow-down" stroke_width=1 data_controller="language" %}
Jinja templates
-
Install with
python -m pip install tablericons[jinja]. -
Adjust your Jinja
Environmentto add the globaltablericonsfunction fromtablericons.jinja. For example:from tablericons.jinja import tablericons from jinja2 import Environment env = Environment() env.globals.update({ "tablericons": tablericons } )
-
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 tabler grid -
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 beNone, 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-linecapstroke-linejoinvector-effect
Note: unlike the SVG code you can copy from tabler grid, there is no default
class.
Examples
An "a-arrow-down” icon:
{{ icon("a-arrow-down") }}
The same icon at 40x40 pixels and a CSS class:
{{ icon("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:
{{ icon("a-arrow-down", stroke_width=1, data_controller="language") }}
Acknowledgements
This package is forked from franciscobmacedo/lucide which in turn is heavely inspired by Adam Johnson's heroicons.
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 tablericons2-1.0.0.tar.gz.
File metadata
- Download URL: tablericons2-1.0.0.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3480ca93c582c0c824f31eb713bfcd29f31bce3a4bcc128cffb421aa05c909b2
|
|
| MD5 |
a2d97c512974720c5fd173a770d69eb9
|
|
| BLAKE2b-256 |
a2171c10e3bfcf267078d1133b4c1db657f665ee126b697ee888c0dd2cce6bde
|
Provenance
The following attestation bundles were made for tablericons2-1.0.0.tar.gz:
Publisher:
main.yml on continis/tablericons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tablericons2-1.0.0.tar.gz -
Subject digest:
3480ca93c582c0c824f31eb713bfcd29f31bce3a4bcc128cffb421aa05c909b2 - Sigstore transparency entry: 2163710382
- Sigstore integration time:
-
Permalink:
continis/tablericons@bea628b96bc6b679fa9d153582d63b015804eb9c -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/continis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@bea628b96bc6b679fa9d153582d63b015804eb9c -
Trigger Event:
push
-
Statement type:
File details
Details for the file tablericons2-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tablericons2-1.0.0-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a193d579710a972a8ce6a57c336cea3a5799faed0c023e3775a0a23dc43dc743
|
|
| MD5 |
df37e7a217f322e52e2636cdfdf4195d
|
|
| BLAKE2b-256 |
29f10d2f4c1c1a2cd481014ab75f5b5a331f8cb60e1a0d19b5a6aa53248ccf7a
|
Provenance
The following attestation bundles were made for tablericons2-1.0.0-py3-none-any.whl:
Publisher:
main.yml on continis/tablericons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tablericons2-1.0.0-py3-none-any.whl -
Subject digest:
a193d579710a972a8ce6a57c336cea3a5799faed0c023e3775a0a23dc43dc743 - Sigstore transparency entry: 2163710413
- Sigstore integration time:
-
Permalink:
continis/tablericons@bea628b96bc6b679fa9d153582d63b015804eb9c -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/continis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@bea628b96bc6b679fa9d153582d63b015804eb9c -
Trigger Event:
push
-
Statement type: