You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@radix-ui/react-avatar

Package Overview
Dependencies
Maintainers
6
Versions
165
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-avatar


Version published
Maintainers
6
Created

Package description

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

Readme

Source

react-avatar

Installation

$ yarn add @radix-ui/react-avatar
# or
$ npm install @radix-ui/react-avatar

Usage

View docs here.

FAQs

Package last updated on 25 Sep 2023

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc