1.0.0 • Published 7 months ago

@saux/avatar v1.0.0

Weekly downloads
-
License
Proprietary
Repository
-
Last release
7 months ago

Avatar Component

The Avatar component is used to display a user's profile picture or initials. It supports custom sizes and fallback initials when no image is provided.

Installation

To use the Avatar component, install the package:

npm install @saux/avatar

Then, import it into your project:

import Avatar from '@saux/avatar';

Usage

Here is an example of how to use the Avatar component:

import React from 'react';
import Avatar from '@saux/avatar';

const App = () => (
  <div>
    <Avatar src="https://via.placeholder.com/150" alt="John Doe" size={50} />
    <Avatar alt="Jane Doe" size={50} />
  </div>
);

export default App;

Props

The Avatar component accepts the following props:

PropTypeDefaultDescription
srcstringundefinedURL of the avatar image (optional).
altstring'Avatar'Alternate text for the avatar (used for fallback initials if no src provided).
sizenumber40The size (width and height in pixels) of the avatar.
classNamestring''Optional extra className for custom styling.

Customization

The Avatar component can be customized using the src, alt, size, and className props. If no src is provided, the component will display the initials extracted from the alt text.

Example

import React from 'react';
import Avatar from '@saux/avatar';

const App = () => (
  <div>
    <Avatar src="https://via.placeholder.com/150" alt="John Doe" size={50} />
    <Avatar alt="Jane Doe" size={50} />
    <Avatar alt="SingleName" size={50} />
    <Avatar size={50} />
  </div>
);

export default App;

License

This component is licensed under the Proprietary License.

1.0.0

7 months ago