Fuse a team into a badge
fuse(["zoe", "priya", "noah", "ava"])Any name, email or id gets a small animal of its own. The same name always gets the same one, and nothing is stored.
pipkin("theo")
No dependencies and about 8.9 KB gzipped. Each pipkin is an SVG string, so it works in React, Vue, Svelte or a plain template.
$ i pipkins
import { pipkin } from "pipkins";
export function Avatar({ id }) {
const svg = pipkin(id, { size: 32 });
return <span dangerouslySetInnerHTML={{ __html: svg }} />;
}
No bundler? Import it from a CDN: https://cdn.jsdelivr.net/npm/pipkins@0/dist/pipkins.min.js
Comments, chats, cursors, leaderboards. Hundreds can share one page, because a pipkin has no ids, defs or filters to collide.
Comments, cursors and team badges, plus the tricks: breed two, fuse a team, change the mood.
fuse(["zoe", "priya", "noah", "ava"])pipkin(user.id)Everything returns a string or a plain object. Bad values throw a TypeError that names the accepted ones.
| Function | Returns | Notes |
|---|---|---|
pipkin(seed, options?) | SVG string | One pipkin. A seed is any name, id or email, a lineage, or a genome. |
fuse(seeds, options?) | SVG string | One pipkin for up to 9 members. Order and duplicates are ignored. |
breed(a, b, { child? }) | genome | Order-free. child picks a sibling (0, 1, 2…). |
pipkinUri, fuseUri | data URI | The same, ready for src attributes. |
describe(seed) | string | Alt text, such as "pink bunny with dot eyes". |
genome(seed) | genome | { id, gen, genes, from, parents }. from says which parent each trait came from. |
share(trait, value) | number | How common a trait value is: share("species", "fox") is 0.16. |
| Option | Default | Notes |
|---|---|---|
size | none | Sets width and height. Leave it out to size with CSS. |
background | false | "circle", "squircle" or "square", in a pale tint of the pipkin's colour. |
mood | "neutral" | happy, sleepy, grumpy, worried, excited, determined, smug. |
animate | false | true, or "hover" to play only while hovered. Load pipkins/motion.css once. |
embedMotion | false | Puts the motion CSS inside the SVG, so it animates on its own, even as an <img>. |
title | none | Accessible name. Without it the SVG is aria-hidden. |
"Theo " is "theo".<defs>, gradients or filters, so hundreds of pipkins can share a page.
Love the new empty state.
Can we keep the bunny?