Skip to main content

Wagtail Icons

Wagtail Icons is package that allows you to add icons (in svg format) on your page, divide them on groups, resize and style displayed icons.

Install

pip install wagtail-svg-icons

Then add wagtail_icons and generic_chooser to your installed apps:

INSTALLED_APPS = [
    ...
    'wagtail_icons',
	'generic_chooser',
	...
]

Usage

IconsField, IconsChooserPanel and IconsChooserBlock

IconsField - Subclass of ForeignKey Field with many-to-one relationship with Icon model. Have all arguments of ForeignKey with defaults:

  • on_delete=models.SET_NULL
  • null=True
  • blank=True

IconsChooserPanel - Subclass of FieldPanel

Extra (optional) argument:

  • group - slug of the group from which icons can be choosen. If not specified all available icons will be displayed.

IconsChooserBlock - Subclass of ChooserBlock

Extra (optional) argument:

  • group - slug of the group from which icons can be choosen. If not specified all available icons will be displayed.
from wagtail_icons.edit_handlers import IconsChooserPanel
from wagtail_icons.fields import IconsField
from wagtail_icons.blocks import IconsChooserBlock

from wagtail.admin.edit_handlers import StreamFieldPanel
try:
    from wagtail.fields import StreamField
    from wagtail.models import Page
    from wagtail import blocks
except ImportError:
    # wagtail version under 3.0
    from wagtail.core.fields import StreamField
    from wagtail.core import blocks
    from wagtail.core.models import Page


class HomePage(Page):
    icon = IconsField()

    body = StreamField([
        ('block_icon', IconsChooserBlock(group='some_group', required=False)),
    ], blank=True)


    content_panels = Page.content_panels + [
        IconsChooserPanel('icon', group='another_group'),
        StreamFieldPanel('body'),
    ]

How to use Icons in templates

The 'icon' tag inserts svg element into page, setting its size and custom_class (if specified). To use 'icon' tag load 'wagtail_icons_tags'

{% load wagtail_icons_tags %}

Icon tag required arguments:

  • icon - instance of Icon model

Icon tag optional arguments:

  • size - icon resize given in format "HEIGHTxWIDTH"
  • class_name - icon class name that can be used to css styling
  • color - custom icon color

Example usage

<!-- Display original size icon -->
{% icon self.icon %}

<!-- Display icon scaled to width 200 and height 250 -->
{% icon self.icon size='250x200' class_name='filter-green' %}

<!-- Display icon scaled to width 200 and height 200 and with class 'my-icon'-->
{% icon self.icon size='200x200' class_name='my-icon' %}

<!-- Display icon scaled to width 200 and height 200 and in color #81b29a-->
{% icon self.icon size='200x200' class_name='my-icon'  color='#81b29a' %}

Metadata

Release files for wagtail-svg-icons 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-svg-icons 0.0.2
File Size Uploaded
wagtail-svg-icons-0.0.2.tar.gz 27.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-svg-icons 0.0.2
File Interpreter ABI Platform
wagtail_svg_icons-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 69.0 kB

Release files / wagtail-svg-icons-0.0.2.tar.gz

Download URL wagtail-svg-icons-0.0.2.tar.gz
Size 27.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d5765a1367336bcb02221a140b3383682b8ba3d36d0c56e5a336b56233d405d4
BLAKE2b-256 checksum
How to use checksums
63132ba6ec71c30c9d7af59365ff0347546a80313d5c39c61d4129d97d39f9a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / wagtail_svg_icons-0.0.2-py3-none-any.whl

Download URL wagtail_svg_icons-0.0.2-py3-none-any.whl
Size 41.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
583480855f395f6231e6a8d3b0afffa80d98110007f234cf754b875e8de6b2ee
BLAKE2b-256 checksum
How to use checksums
92ce3577e32a79007a2f34db732838b57624450d63389c3e81dac64578bf50fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page