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.6

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.6
File Size Uploaded
ui_avatars-1.2.6.tar.gz 6.8 kB Details

Built distribution (wheel)

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

Total release size: 14.5 kB

Release files / ui_avatars-1.2.6.tar.gz

Download URL ui_avatars-1.2.6.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
960d12f52ce883e9ded21b86fa946d2dce88a9313ec793c566436526ee7e8704
BLAKE2b-256 checksum
How to use checksums
ef0a0fee2bb8f8b68b21aeb9d2586095fe9be31d734c640a0ad5e318f17e1e9b
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 Sep 2, 2026.

Transparency log

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

Download URL ui_avatars-1.2.6-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd6837568e26ab060b6c594a7af48bfe127c56222428d4cdf2e8fe37d8dba416
BLAKE2b-256 checksum
How to use checksums
cc100ccac84ee1dcf12f258421b33e8beb65d1366933e74167d5972b53067a06
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 Sep 2, 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

This release

1.2.6 This release

2 release files

1.2.5

2 release files

1.2.4

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