New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ravatar

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ravatar

React Avatar Placeholder

latest
Source
npmnpm
Version
0.1.8
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Ravatar 🎭

A customizable React avatar placeholder component with multiple stylish avatar sets.

Features

  • 📦 Multiple avatar sets (3D, Bluey, Memo, Notion, Teams, Toon, Upstream, Vibrent)
  • 🎲 Random avatar selection from any category
  • 🎨 Fully customizable sizing and styling
  • 🔄 Custom fallback support
  • 🛡️ Error handling
  • 📱 Responsive design

Installation

npm install ravatar
# or
yarn add ravatar

Usage

import { Ravatar } from 'ravatar';

function App() {
  return (
    <div>
      {/* Basic usage */}
      <Ravatar name="3d" number={1} />
      
      {/* Custom sizing */}
      <Ravatar name="notion" number={5} width={64} height={64} />
      
      {/* With custom styles */}
      <Ravatar 
        name="toon" 
        number={3} 
        className="custom-avatar" 
        style={{ borderRadius: '50%' }} 
      />
      
      {/* With fallback */}
      <Ravatar
        name="teams"
        number={2}
        fallback={<span>Avatar failed to load</span>}
      />

      {/* Random avatar from any category */}
      <Ravatar random={true} />

      {/* Random avatar from selected category */}
      <Ravatar name="3d" random={true} />
    </div>
  );
}

⚠️ Performance Warning

Please note that when importing the main Ravatar component directly, all avatar images are loaded at once, which increases your bundle size, loading time and bandwidth usage by approximately 1.4 MB.

Optimized Imports

To minimize bundle size, loading time and bandwidth usage, you can import individual avatar components directly:

// Import only a specific avatar component
import { RavatarTeams } from 'ravatar';
import { Ravatar3D } from 'ravatar';
import { RavatarToon } from 'ravatar';
// ... and so on

function App() {
  return (
    <div>
      {/* Teams style avatar */}
      <RavatarTeams number={2} />
      
      {/* 3D style avatar */}
      <Ravatar3D number={3} />
      
      {/* Toon style avatar */}
      <RavatarToon random={true} />
    </div>
  );
}

This approach only loads the specific avatar set you need, significantly reducing the bundle size. All avatar sets have dedicated components that can be imported individually.

Avatar Sets

Ravatar includes the following avatar sets:

NameDescriptionCountComponent
3d3D style avatars5Ravatar3D
blueyBlue-themed avatars10RavatarBluey
memoMemo-style avatars10RavatarMemo
notionNotion-inspired avatars10RavatarNotion
teamsTeams-style avatars9RavatarTeams
toonCartoon avatars10RavatarToon
upstreamUpstream collection10RavatarUpstream
vibrentVibrant/colorful avatars10RavatarVibrent

Props

PropTypeDefaultDescription
namestringundefinedAvatar set name (one of: '3d', 'bluey', 'memo', 'notion', 'teams', 'toon', 'upstream', 'vibrent'). If not provided, a random category will be selected
numbernumberundefinedAvatar number within the selected set (1-based index). If not provided, a random number will be selected within the category
randombooleanfalseIf true, selects a random avatar from any category, ignoring name and number props
altstring'React Avatar'Alternative text for the avatar image
widthnumber | 'auto''auto'Width of the avatar
heightnumber | 'auto''auto'Height of the avatar
classNamestring''Additional CSS class names
styleCSSProperties{}Additional inline styles
customSrcstringundefinedOptional custom image path to override the generated path
fallbackReactNodeundefinedFallback content to display if the image fails to load

Development

# Install dependencies
npm install

# Run development mode
npm run dev

# Build for production
npm run build

Credits

Special thanks to Alohe for providing the beautiful avatar images used in this package. The avatars are sourced from the Alohe Avatars repository.

Keywords

ravatar

FAQs

Package last updated on 27 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts