Introducing the heroicons Python Package

2021-04-16 Only iconography can tell us what is going on here.

heroicons is a free SVG icon set for your websites, from the creators of tailwindcss. SVG icons are great - they’re small, they sit inline in your HTML, and you can scaled and colour them with plain HTML and CSS. And heroicons is a great icon set - minimal, clear, and consistent.

I’ve decided to use both tailwindcss and heroicons in DB Buddy. Since others have shown interest I’ve turned my work into a package.

heroicons itself provides the icon set on their web page for copy-pasting, but this gets tiresome. Inline SVG’s have no labels, and bloat template files. heroicons provides React and Vue packages to summon icons by name, and a zip file for the rest of us.

My new python package heroicons bundles a shrunken version of that zip file, to provide both Django and Jinja template tags. Using these you can include an icon by name, set its size, and add extra HTML attributes.

For example, in a Django template:

{% load heroicons %}

{% heroicon_outline "academic-cap" size=48 class="h-4 w-4 inline" data_controller="academia" %}
{% endhighlight %}

It currently bundles version 1.0.1 of the icon set, and I’ll update it as new releases come out. Check it out on PyPI.

Fin

Thanks to Steve Schoger for creating such great icons!

—Adam


📙👉Speed Up Your Django Tests👈📙


Subscribe via RSS, Twitter, or email:

One summary email a week, no spam, I pinky promise.

Related posts:

Tags: django, python