
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-name-initials-avatar
Advanced tools
Npm Package Url - https://www.npmjs.com/package/react-name-initials-avatar
The react-name-initials-avatar is a lightweight and customizable React component that generates avatars based on user names or initials. This component is ideal for user profile displays, comment sections, or any application where you want to visually represent users with avatars.

yarn add react-name-initials-avatar
OR
npm install react-name-initials-avatar
To use the component, import it into your React application:
import {NameInitialsAvatar} from 'react-name-initials-avatar';
function UserProfile(props) {
const { username } = props;
return (
<div className="user-profile">
<NameInitialsAvatar
name={username}
/>
<h2>{username}</h2>
</div>
);
}
export default UserProfile;
In the above example, the NameInitialsAvatar component generates an avatar based on the user's name initials. You can customize the avatar's size, background color, border radius, font weight and text color according to your design.
| Key | Default | Type |
|---|---|---|
name (required) | undefined | string |
bgColor | white | string |
textColor | black | string |
size | 40px | string | number |
borderRadius | 50% | string |
textWeight | bold | string | number |
textSize | 16px | string | number |
borderColor | black | string |
borderStyle | solid | string |
borderWidth | 2px | string | number |
shape | undefined | "circle" | "square" |
autoColor | false | boolean |
initialsLength | undefined | 1 | 2 | 3 |
"40px", "40", or 40 (auto-converts to px)"16px", "16", or 16 (auto-converts to px)"2px", "2", or 2 (auto-converts to px)borderRadius takes precedence over shape if both are providedtrue, automatically generates a consistent background color based on the name. Note: bgColor takes precedence over autoColor if both are provided1 shows "J", 2 shows "JD", 3 shows "JMD"<NameInitialsAvatar name="John Doe" />
Each name generates a unique, consistent color:
<NameInitialsAvatar name="John Doe" autoColor textColor="white" />
<NameInitialsAvatar name="Jane Smith" autoColor textColor="white" />
<NameInitialsAvatar name="Circle" shape="circle" />
<NameInitialsAvatar name="Square" shape="square" />
<NameInitialsAvatar name="John Michael Doe" initialsLength={1} /> {/* J */}
<NameInitialsAvatar name="John Michael Doe" initialsLength={2} /> {/* JD */}
<NameInitialsAvatar name="John Michael Doe" initialsLength={3} /> {/* JMD */}
<NameInitialsAvatar
name="John Doe"
bgColor="#3498db"
textColor="white"
size={60}
borderRadius="12px"
borderColor="#2980b9"
borderWidth={3}
/>
bgColor > autoColor > default ("white")borderRadius > shape > default ("50%")FAQs
Creating Stylish Initial-Based Avatars in React
The npm package react-name-initials-avatar receives a total of 866 weekly downloads. As such, react-name-initials-avatar popularity was classified as not popular.
We found that react-name-initials-avatar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.