@makozi/react-user-avatar-generator
Version:
Dynamically generates placeholder avatars using initials, random colors, or uploaded images.
70 lines (47 loc) • 2.27 kB
Markdown
Dynamically generates placeholder avatars using initials, random colors, or uploaded images. Ideal for social platforms and apps with profiles.
- Generate avatars from **initials** or **uploaded images**
- Random background colors or custom themes
- Supports **circle** or **square** shapes
- Auto fallback to initials if image fails
- **SVG/Canvas**-ready
- Lightweight and customizable
---
```bash
npm install @makozi/react-user-avatar-generator
```
```
yarn add @makozi/react-user-avatar-generator
```
```
import { Avatar } from "@makozi/react-user-avatar-generator";
export default function App() {
return (
<div>
<Avatar name="John Doe" size={60} />
<Avatar name="Jane Smith" src="https://example.com/avatar.jpg" size={60} shape="square" />
</div>
);
}
```
| Prop | Type | Default | Description |
|-----------------|--------------------------|-------------|------------------------------------|
| name | string | "User" | Name used to generate initials |
| src | string | null | Image URL to display |
| size | number | 50 | Avatar size in pixels |
| shape | "circle" or "square" | "circle" | Shape of the avatar |
| backgroundColor | string | random | Background color |
| textColor | string |
| fontSize | number | 18 | Font size for initials |
| style | object | {} | Custom CSS styles |
Project Home: [https://github.com/makozi/react-user-avatar-generator](https://github.com/makozi/react-user-avatar-generator)
Repository: [https://github.com/makozi/react-user-avatar-generator](https://github.com/makozi/react-user-avatar-generator)
MIT © Makozi Marizu-Ibewiro