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 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.1.0.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.1.0-py3-none-any.whl (3.2 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_material_icons-0.1.0.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.1.0.tar.gz
Algorithm Hash digest
SHA256 f390e20350e69d5d11c33adfb865642618dca3456d52348a186999e7116dea65
MD5 42bb6b1f41b48010577cfe77588aa49c
BLAKE2b-256 19947357f80f0a82e4a34e6e241205510db7040fa138257d711fb0dcbe0058e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_material_icons-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d527e25554e2fdeb1f232c9c829b6e627353e3b5eded2ad2bcc9fbbf9af1795
MD5 8f43c8e5812477dd3266a718aa8b2c41
BLAKE2b-256 28816c6517f5ee409e215a9ecf2cad86fe7d3c75c6967cf2e0feec644cd8378b

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