Socket
Socket
Sign inDemoInstall

@radix-ui/react-avatar

Package Overview
Dependencies
Maintainers
6
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-avatar


Version published
Weekly downloads
969K
increased by4.83%
Maintainers
6
Weekly downloads
 
Created

What is @radix-ui/react-avatar?

@radix-ui/react-avatar is a React component library for creating customizable avatar components. It provides a simple and flexible way to display user avatars with support for fallback images and initials.

What are @radix-ui/react-avatar's main functionalities?

Basic Avatar

This code demonstrates how to create a basic avatar with an image and a fallback initial using @radix-ui/react-avatar.

```jsx
import { Avatar, AvatarImage, AvatarFallback } from '@radix-ui/react-avatar';

function BasicAvatar() {
  return (
    <Avatar>
      <AvatarImage src="https://example.com/user.jpg" alt="User" />
      <AvatarFallback>U</AvatarFallback>
    </Avatar>
  );
}
```

Custom Size Avatar

This code shows how to create an avatar with a custom size by applying a custom CSS class.

```jsx
import { Avatar, AvatarImage, AvatarFallback } from '@radix-ui/react-avatar';
import './styles.css'; // Assume this file contains the custom size styles

function CustomSizeAvatar() {
  return (
    <Avatar className="custom-avatar-size">
      <AvatarImage src="https://example.com/user.jpg" alt="User" />
      <AvatarFallback>U</AvatarFallback>
    </Avatar>
  );
}
```

Avatar with Fallback Image

This code demonstrates how to use a fallback image when the main avatar image fails to load.

```jsx
import { Avatar, AvatarImage, AvatarFallback } from '@radix-ui/react-avatar';

function AvatarWithFallbackImage() {
  return (
    <Avatar>
      <AvatarImage src="https://example.com/nonexistent.jpg" alt="User" />
      <AvatarFallback>
        <img src="https://example.com/fallback.jpg" alt="Fallback" />
      </AvatarFallback>
    </Avatar>
  );
}
```

Other packages similar to @radix-ui/react-avatar

FAQs

Package last updated on 16 Aug 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc