Use tablericons in your Django and Jinja templates.
Project description
Use tablericons in your Django and Jinja templates.
Requirements
Python 3.9 to 3.13 supported.
Django 4.2 to 5.1 supported.
Usage
The tablericons-new package supports both Django templates and Jinja templates. Follow the appropriate guide below.
Django templates
Install with python -m pip install tablericons-new[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 these tags to render SVG icons in their corresponding styles:
tablericon_outline
tablericon_filled
The tags take these arguments:
name, positional: the name of the icon to use. You can see the icon names on the tablericons.com 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 for outline and solid, 20 for mini, and 16 for micro. Can 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
Examples
An outline “school” icon:
{% tablericon_outline "school" %}
The same icon, solid, at 40x40 pixels, and a CSS class:
{% tablericon_outline "school" size=40 class="mr-4" %}
That icon again, but with the paths changed to a narrower stroke width, and a “data-controller” attribute declared:
{% tablericon_outline "school" stroke_width=1 data_controller="academia" %}
Jinja templates
Install with python -m pip install tablericons-new[jinja].
Adjust your Jinja Environment to add the global tablericon_* functions from tablericons.jinja. For example:
from tablericons.jinja import ( tablericon_outline, tablericon_filled, ) from jinja2 import Environment env = Environment() env.globals.update( { "tablericon_outline": tablericon_outline, "tablericon_filled": tablericon_filled, } )
Now in your templates you can call those functions, which render <svg> icons corresponding to the icon styles in the set. The functions take these arguments:
name, positional: the name of the icon to use. You can see the icon names on the tablericons.com 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 for outline and solid, 20 for mini, and 16 for micro. 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 tablericons.com, there is no default class.
Examples
An outline “egg” icon:
{{ tablericon_outline("egg") }}
The same icon, solid, at 40x40 pixels, and a CSS class:
{{ tablericon_filled("egg", size=40, class="mr-4") %}
That icon again, but with the paths changed to a narrower stroke width, and a “data-controller” attribute declared:
{{ tablericon_outline("egg", stroke_width=1, data_controller="academia") %}
Acknowledgements
This package is heavely inspired by [Adam Johnson’s heroicons](https://github.com/gartmeier/heroicons). It’s actually mostly copied from it so a huge thanks Adam!
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 tablericons_new-1.0.0.tar.gz.
File metadata
- Download URL: tablericons_new-1.0.0.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4972ef3e884c3346d2cec77f22341d26f3208dce35aaa6ad09272a837be0f64b
|
|
| MD5 |
9873353ecf2745991423e92f13318fec
|
|
| BLAKE2b-256 |
a7bf327abe69e897087b8b9bdb52321038a3aa7be7d61c9ca5d02bd6b19d3b2a
|
Provenance
The following attestation bundles were made for tablericons_new-1.0.0.tar.gz:
Publisher:
main.yml on gartmeier/tablericons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tablericons_new-1.0.0.tar.gz -
Subject digest:
4972ef3e884c3346d2cec77f22341d26f3208dce35aaa6ad09272a837be0f64b - Sigstore transparency entry: 156126684
- Sigstore integration time:
-
Permalink:
gartmeier/tablericons@ba4ae84d8be0ba5f52baca11c0e558ba85b43f63 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/gartmeier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@ba4ae84d8be0ba5f52baca11c0e558ba85b43f63 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tablericons_new-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tablericons_new-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c38fab2569985fc5346483f161cba63203b1c8387c34e64f510f9c6162233d9
|
|
| MD5 |
8ec1cb665764ae748e8d57220f618629
|
|
| BLAKE2b-256 |
d0d244eeb018c8a2beadf87116009224b8df7e6b44894e296cc10a9fd05d5d10
|
Provenance
The following attestation bundles were made for tablericons_new-1.0.0-py3-none-any.whl:
Publisher:
main.yml on gartmeier/tablericons
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tablericons_new-1.0.0-py3-none-any.whl -
Subject digest:
7c38fab2569985fc5346483f161cba63203b1c8387c34e64f510f9c6162233d9 - Sigstore transparency entry: 156126685
- Sigstore integration time:
-
Permalink:
gartmeier/tablericons@ba4ae84d8be0ba5f52baca11c0e558ba85b43f63 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/gartmeier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@ba4ae84d8be0ba5f52baca11c0e558ba85b43f63 -
Trigger Event:
push
-
Statement type: