API reference
Options
The package's main export is palletface.
palletface(seed: string, options?: PalletfaceOptions): string
| Input | Type | Default | Behavior |
|---|---|---|---|
seed |
string |
Required | Drives the design. Empty and Unicode strings are valid. |
style |
StyleSlug |
'pixel-sprite' |
Style slug from your installed version. |
px |
number |
80 |
SVG width and height in CSS pixels. Must be finite and greater than zero. |
name |
string |
Seed | Supplies the glyph for initial styles. The palette still comes from the seed. |
The return value has an SVG namespace, dimensions, and a viewBox. Invalid seed, options, name, or style types throw TypeError. Invalid sizes throw RangeError. An unknown style slug throws Error.
Initial styles use the first ASCII letter or digit after accent normalization. Élodie yields E. An explicit empty name or a name without a matching character yields ?.
Style picker
Use the exports from the installed package to build a picker. Each STYLES entry has a slug, title, note, and draw(seed, px, name?).
import { STYLES } from 'palletface'
const choices = STYLES.map(({ slug, title }) => ({ value: slug, label: title }))
TypeScript can import PalletfaceOptions, StyleSlug, and AvatarStyle from the package entry point.
Stability
- The same seed and options produce the same SVG in supported runtimes.
- Minor and patch releases never change existing avatars. Only a major release can, and its release notes say which styles changed. The default
^1.0.0range fromnpm install palletfacestays on one major version. To lock an exact version, usenpm install --save-exact palletface. - Use an opaque, stable ID as the seed. Keep emails, tokens, and secrets out of seeds. Different seeds can produce identical or similar avatars.