Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-avatar

Package Overview
Dependencies
Maintainers
6
Versions
189
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-avatar

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
decreased by-7.67%
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 13 Dec 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