Avatar
Import
To use the Avatar component in your project, import it as follows:
import { Avatar } from "@purrfect-ui/components";
Usage
The Avatar component is designed to be simple yet powerful, allowing you to display user profiles or placeholders effortlessly. Here's an example of its basic usage:
Basic Usage
const avatars = [
{
name: "Raúl García",
src: "https://unavatar.io/github/kuranio",
description: "Frontend Developer",
},
{
name: "Héctor Olivares",
src: "https://unavatar.io/github/hectorOliSan",
description: "Backend Developer",
},
{
name: "Joaquin Pastore",
src: "https://unavatar.io/github/JoaquinJPB",
description: "Frontend Developer",
},
{
name: "Alvaro Estévez",
src: "https://unavatar.io/github/alvaroem17",
description: "Web Developer",
},
];
export function AvatarDemo() {
return (
<div className="flex -space-x-4 rtl:space-x-reverse mb-4">
{avatars.map((avatar, idx) => (
<div key={idx}>
<Avatar
name={avatar.name}
src={avatar.src}
description={avatar.description}
/>
</div>
))}
</div>
);
}
export default AvatarDemo;
Key Features
-
Customizable Sizes: Choose between small, medium, or large avatars to fit your design needs.
-
Dynamic Shapes: Supports both circular and square shapes for flexible styling.
-
Fallback Options: Displays initials or a default icon when no image is provided.
-
Accessibility Friendly: Includes alt text support for improved screen reader compatibility.
-
Integrates Seamlessly: Works with your existing themes and supports custom class names for extended styling.