Skip to main content

Use Google's Material Icons in your Python applications

Project description

Python Material Icons

Use Google's Material Icons in your Python applications.

This library provides access to the full set of Material Icons in three distinct styles: outlined, round, and sharp. Icons are converted from SVG to PNG at runtime using CairoSVG, with automatic caching based on icon name, size, color, and style.

When loading an icon, it will return a PNG byte stream that you can use in any way you see fit.

Installation

pip install python-material-icons

Usage

With Pillow:

from material_icons import MaterialIcons, IconStyle
from PIL import Image
import io

# Load an icon as PNG bytes
icons = MaterialIcons()
png_bytes = icons.get("cancel", size=48, color="#ff0000", style=IconStyle.ROUND)

# Use with Pillow
image = Image.open(io.BytesIO(png_bytes))
image.show()

With pygame:

import pygame
from material_icons import MaterialIcons, IconStyle

icons = MaterialIcons()

# Load an icon as PNG bytes
png_bytes = icons.get("cancel", size=48, color="#ff0000", style=IconStyle.SHARP)

# Use with pygame
surface = pygame.image.load(io.BytesIO(png_bytes))

Parameters

  • name (str): The Material icon name, e.g. "cancel", "check_box", "signal_cellular_4_bar".
  • size (int, default=24): The output icon size in pixels (square).
  • color (str, default="#000000"): The icon color as a hex string.
  • style (IconStyle, default=IconStyle.OUTLINED): The icon style - IconStyle.OUTLINED, IconStyle.ROUND, or IconStyle.SHARP.

Icon Styles

Material Icons come in three distinct styles:

  • Outlined (IconStyle.OUTLINED): Clean, minimal outlined icons (default)
  • Round (IconStyle.ROUND): Rounded corners and edges for a softer look
  • Sharp (IconStyle.SHARP): Angular, sharp-edged icons for a more geometric feel
# Get the same icon in different styles
outlined = icons.get("home", style=IconStyle.OUTLINED)
round_icon = icons.get("home", style=IconStyle.ROUND)
sharp = icons.get("home", style=IconStyle.SHARP)

Caching

Icons are cached automatically based on (name, size, color, style). Subsequent calls with the same parameters return instantly without re-rendering.

Examples

A pygame icon gallery example is available in the examples directory, install pygame and run it like so:

python examples/pygame-gallery.py

Contribution

We welcome contributions!

  • Open issues for bugs or feature requests
  • Submit pull requests to improve the code, documentation, or packaging.
  • The icon set is fetched automatically in the build pipeline, so you don't need to commit icons to the repository.

Distribution

To build and upload to pypi, first update version pyproject.toml then run run:

python -m build
python -m twine upload --repository testpypi dist/*
python -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_material_icons-0.3.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_material_icons-0.3.1-py3-none-any.whl (3.2 MB view details)

Uploaded Python 3

File details

Details for the file python_material_icons-0.3.1.tar.gz.

File metadata

  • Download URL: python_material_icons-0.3.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for python_material_icons-0.3.1.tar.gz
Algorithm Hash digest
SHA256 47dae6e42a35991a2c7402f9621891e468a364aaa50cab8e083de387cacf9bab
MD5 d60c594b7f1ec0e43e4f6e46164e3795
BLAKE2b-256 da78b6fba05118ec2e7e01bc66f4780fcf3a1d73a65a05b46518545d53488be0

See more details on using hashes here.

File details

Details for the file python_material_icons-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_material_icons-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 43a979b30416bce4f171a604dae827cfe14b6bbd2fac3f5abc0ce821d316433f
MD5 718c94c3e644f7b2401d57237535f97c
BLAKE2b-256 524adacbf6a010ed0c2c7e73759d7d48c72fe405d431c9107d4370a32e3b3601

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page