boring-avatars
repository·master·Indexed 27 days ago
https://github.com/boringdesigners/boring-avatarsA tiny JavaScript React library that generates custom, SVG-based, round avatars from any username and color palette. It features multiple visual variants including marble, beam, pixel, sunset, ring, and bauhaus, and supports customization of size, colors, and shape.
What's inside boring-avatars
- For large-scale avatar generation or to avoid using the React library, a subscription-based API service is available via Gumroad.
Install boring-avatars via npm
masterInstall the
boring-avatarspackage using npm to use the React component for generating unique SVG-based user profile avatars.npm install boring-avatarsUse the Avatar component
masterImport the
Avatarcomponent fromboring-avatarsand provide anameprop (username, email, or any random string) to generate a unique avatar.import Avatar from 'boring-avatars'; <Avatar name="Maria Mitchell" />;Customize Avatar colors
masterPass an array of color strings to the
colorsprop to define a custom color palette for the avatar.<Avatar name="Grace Hopper" colors={["#fb6900", "#f63700", "#004853", "#007e80", "#00b9bd"]}/>Make Avatar square
masterAdd the
squareboolean prop to render the avatar as a square instead of the default circular shape.<Avatar name="Helen Keller" square/>Customize Avatar size
masterUse the
sizeprop to set the dimensions of the avatar using a number or a string (e.g.,88or"88px").<Avatar name="Ada Lovelace" size={88}/>Customize Avatar variant
masterUse the
variantprop to switch between different visual themes. Available options are:marble,beam,pixel,sunset,ring, andbauhaus.<Avatar name="Alice Paul" variant="beam"/>Configure Avatar component props
masterThe
Avatarcomponent accepts several props to customize the appearance of the generated avatar:name(string): The seed used to generate the avatar. Defaults toClara Barton.variant(oneOf:marble,beam,pixel,sunset,ring,bauhaus): Changes the visual theme. Defaults tomarble.size(number | string): Sets the dimensions. Defaults to40px.colors(array): An array of color strings to define the palette.square(boolean): If true, renders a square avatar instead of circular. Defaults tofalse.title(boolean): Enables a title attribute. Defaults tofalse.
Use the Avatar component
masterThe
Avatarcomponent is the primary entrypoint for generating various avatar styles. It accepts avariantto choose the visual style, acolorsarray for the color palette, and anamefor seed-based generation.Available variants include:
pixelbauhausringbeamsunsetmarble
Note:
geometricis deprecated (usebeam) andabstractis deprecated (usebauhaus).Configure AvatarProps
masterThe
Avatarcomponent accepts the following props:Prop Type Default Description variantkeyof typeof AVATAR_VARIANTS'marble'The visual style of the avatar. colorsstring[]['#92A1C6', '#146A7C', '#F0AB3D', '#C271B4', '#C20D90']An array of hex color strings used for the generation. namestring'Clara Barton'The name used to seed the avatar generation. titlebooleanfalseWhether to include a title. sizestring'40px'The dimensions of the avatar. squarebooleanfalseWhether to render the avatar as a square instead of a circle.