Skip to main content

ui-avatars

PyPI CI Coverage Downloads License

Deterministic avatar URLs for light and dark designs: Gravatar or Libravatar photos falling back to colored initials via ui-avatars.com. Same input, same URL, always.

Install

pip install ui-avatars

Usage

from ui_avatars import avatar_url

avatar_url(name="Ada Lovelace", email="ada@example.com")
# Gravatar photo, falling back to generated initials

avatar_url(name="Ada Lovelace")
# straight ui-avatars.com URL, no Gravatar lookup

avatar_url(email="ada@example.com")
# initials from the first two letters of the email

avatar_url(name="Ada Lovelace", alpha=0.75, size=256, rounded=True)
# alpha, size, and ui-avatars.com rendering options as one-off overrides

avatar_url(name="Ada Lovelace", color="#dc2626")
# pick a specific color, skipping the palette

avatar_url(name="Ada Lovelace", alpha=1, background="#000")
# pin the background, let the text color rotate with the palette

avatar_url(name="Ada Lovelace", font_color="#fff")
# pin the text color, let the background rotate with the palette

avatar_url(name="Ada Lovelace", email="ada@example.com", format="png")
# force png or svg, note Gravatar errors for svg default images

avatar_url(name="Ada Lovelace", email="ada@example.com", source="libravatar")
# look up the photo on Libravatar instead of Gravatar

avatar_url(name="Ada Lovelace", email="ada@example.com", source="secure.gravatar.com")
# use a custom Gravatar-compatible photo source

avatar_url(name="Ada Lovelace", region="eu")
# use the EU ui-avatars.com endpoint for generated initials

avatar_url(name="Ada Lovelace", host="avatars.example.com")
# use a custom or self-hosted UI Avatars endpoint

avatar_url(name="Ada Lovelace", mask="hexagon")
# crop the image to a hexagon via wsrv.nl

avatar_url(name="Ada Lovelace", format="webp", proxy="images.example.com")
# use a self-hosted wsrv.nl instance instead of the public api

Configuration

Reconfigure the shared avatars instance once, at startup, to change the palette for every call:

from ui_avatars import avatars

avatars.configure(colors=["#1d4ed8", "#b91c1c"], size=256, rounded=True)

Or build your own instance instead:

from ui_avatars import Avatars

avatars = Avatars(colors=["#1d4ed8", "#b91c1c"], size=256)
avatars.build(name="Ada Lovelace", email="ada@example.com")

The default palette is tailwind_colors's RAINBOW_500. You can swap the whole palette like so:

from tailwind_colors import TCH

avatars.configure(colors=TCH.RAINBOW_300)

For an independent background/text color instead of one tinted from the other, use a (background, text) tuple as a colors entry — alpha still applies to whichever background results:

avatars.configure(colors=[("#fee2e2", "#ef4444"), ("#ffedd5", "#f97316")])

Development

poetry install
poetry run pytest
poetry run ruff check .

License

MIT

Metadata

Release files for ui-avatars 1.2.4

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

Source distribution (sdist)

Source distribution for ui-avatars 1.2.4
File Size Uploaded
ui_avatars-1.2.4.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ui-avatars 1.2.4
File Interpreter ABI Platform
ui_avatars-1.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / ui_avatars-1.2.4.tar.gz

Download URL ui_avatars-1.2.4.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
16751f55813cd37072ebbd4275189c03ffc2e79db01ba60fc11dc5bdd5c75c3d
BLAKE2b-256 checksum
How to use checksums
bb374edcf0df5f062885ce594149c4a53e90288e6b7a3593985315437ec67ca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / ui_avatars-1.2.4-py3-none-any.whl

Download URL ui_avatars-1.2.4-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
359e21b293afd53b5360a1ff5af18f31db10d02f44471b48b5d13632e69439f7
BLAKE2b-256 checksum
How to use checksums
89f4c9795b26bac10cc9b034332001dddd68ce5f42f1e53f3a6da63d16193b2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

1.2.14

2 release files

1.2.13

2 release files

1.2.12

2 release files

1.2.11

2 release files

1.2.9

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

This release

1.2.4 This release

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

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