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,IconStyle.SHARPorIconStyle.TWOTONE.
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 - TWOTONE (
IconStyle.TWOTONE): Two toned icons
# 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/*
Metadata
Release files for python-material-icons 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_material_icons-0.3.2.tar.gz | 1.5 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_material_icons-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.9 MB
Release files / python_material_icons-0.3.2.tar.gz
| Download URL | python_material_icons-0.3.2.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eeab036bd2fef04baf435b97a61660c44e96e64488ac8c6997aa0e3cd0c1aac9
|
|
BLAKE2b-256 checksum How to use checksums |
68eb9eb6bb6be24e7d0492efba47873b005672be26d913e33852a9ccb518a29f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / python_material_icons-0.3.2-py3-none-any.whl
| Download URL | python_material_icons-0.3.2-py3-none-any.whl |
|---|---|
| Size | 4.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc0b6a776c3b1e36e33458ba0d6e7a726de7c2e947b7792781e8186094f7fae0
|
|
BLAKE2b-256 checksum How to use checksums |
9453dd22653f9ba3251601b03834f71de5cd330b24e771be5ef0009a26d3b330
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|