default-avatar
Version:
A customizable React component to generate default avatars with initials and themed colors.
73 lines (49 loc) • 2.64 kB
Markdown
# 🧑🎨 Default Avatar Generator
A customizable React component to generate default avatars with initials and themed colors — no images needed!
## ✨ Features
- 🎨 Auto-generated colors (random or based on name)
- 🌙 Supports light and dark themes
- 🟠 Choose from `circle`, `square`, or `rounded` shapes
- 🔤 Custom font and avatar size
- ⚡ Lightweight, no external dependencies
## 📦 Installation
```bash
npm install default-avatar
# or
yarn add default-avatar
```
## 🔧 Usage
```tsx
import Avatar from 'default-avatar';
<Avatar name="Alice" />
<Avatar name="Bob" shape="square" />
<Avatar name="Charlie" shape="rounded" radius={10} />
<Avatar name="Dana" useNameBasedColor theme="light" />
```
## ⚙️ Props
| Prop | Type | Default | Description |
| ------------------- | --------------------------------------- | ------------------------------- | ------------------------------------------------------- |
| `name` | `string` | _required_ | User's name (used for initials and optional color seed) |
| `shape` | `'circle'` \| `'square'` \| `'rounded'` | `'circle'` | Avatar shape |
| `radius` | `string` \| `number` | _required if `shape="rounded"`_ | Corner radius for rounded shapes |
| `theme` | `'dark'` \| `'light'` | `'dark'` | Color mode |
| `useNameBasedColor` | `boolean` | `false` | Generate consistent colors from name |
| `size` | `number` | `50` | Size in pixels |
| `fontFamily` | `string` | `'Arial, sans-serif'` | Font for the initials |
## 🖼 Example
<img src="public/1.png" width="80" alt="Example Avatar" />
<img src="public/2.png" width="80" alt="Example Avatar" />
<img src="public/3.png" width="80" alt="Example Avatar" />
<img src="public/4.png" width="80" alt="Example Avatar" />
<img src="public/5.png" width="80" alt="Example Avatar" />
## 📄 License
[MIT](./LICENSE)
## 👨💻 Author
Made with ❤️ by [Vinay Garg](https://github.com/xvinay28x)