# @s-ui/react-molecule-avatar

> The Avatar component is the representation of a user.

Latest version **1.18.0** (published 2025-05-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @s-ui/react-molecule-avatar
pnpm add @s-ui/react-molecule-avatar
yarn add @s-ui/react-molecule-avatar
bun add @s-ui/react-molecule-avatar
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.18.0 |
| Published | 2025-05-05 |
| First published | 2020-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 18.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 146 |
| Maintainers | alejandro.ferrante, ivanmlaborda, salvador.juan, andresin87.adevinta, izeller, gfabregoadv, a.ferrer, ignacio_navarro, oscar_ramirez, jordi.munoz, joanleon-adv, aitor.rodriguez, luis-garrido, jenifer.lopez, isabelgomez87, pa.chruscinski.ext, schibstedspain, alfredo.arronte, belen.santos, xavi_ballestar, ferrangbtw, jamile.radloff, davidmartin2108, sergi.quintela, estefania_garcia, carlosvillu-adevinta, miriam-gil, arnau.guell, ferran.simon, victor.perez.adevinta, mariapaula.forero.ext, oscar.gomez, david.nieto, oriol.puig, nacho_torrella, xavi.murcia, ignacio.rodriguez, francisco.ruiz.lloret, sziauberyte, alfredo.zimperz, andresadv, javiauso, alverd004, marian.lucaci, pablogs, alisa_bayanova, cristhianb, sergiocollado, pablo.rey-adevinta, beatrizip, alex.castells, david.cuadrado.ext, giovanny.sayas.ext, patricio.sartore, azahara, marc.benito, sergio.escano, cristina.rodriguez.duque, pol.valls, frandelacasa-adevinta, carolina.mallo.ext, daniel.perez.ext, hpintos_adevinta, carlos.gonzalezl, albert.peiro, oscar-raig-adevinta, thomas.page.ext, sebastian.badea.adevinta, victoria.pasichnyk.ext, sendami.luque.ext, luz_adv, alfredo.narvaez, ruben-martin, dann41, emiliovz, adria.velardos, arturo.vicente, diegomr, sergi.martinez.adevinta, guillemgc3, frontend-jobs, javiermiguel, atilioscolaroadv, crotundu.adevinta, candymd, florinz, denis_z, anya_ok |
| Keywords | @s-ui, react, component, molecule, avatar |

## Links

- npm: https://www.npmjs.com/package/@s-ui/react-molecule-avatar
- Repository: https://github.com/SUI-Components/sui-components
- Homepage: https://sui-components.vercel.app/
- Issues: https://github.com/SUI-Components/sui-components/issues?q=is%3Aopen+label%3A%22Component%3A+avatar%22
- npm.io page: https://npm.io/package/@s-ui/react-molecule-avatar

## Dependencies (3)

- [@s-ui/react-atom-image](https://npm.io/package/@s-ui/react-atom-image.md) 2
- [@s-ui/react-atom-skeleton](https://npm.io/package/@s-ui/react-atom-skeleton.md) 1
- [@s-ui/react-primitive-injector](https://npm.io/package/@s-ui/react-primitive-injector.md) 1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.18.0 (latest) — 2025-05-05
- 1.17.0 — 2022-10-17
- 1.16.0 — 2022-10-06
- 1.15.0 — 2022-10-03
- 1.14.0 — 2022-09-29
- 1.13.0 — 2022-08-12
- 1.12.0 — 2022-06-22
- 1.11.0 — 2022-04-05
- 1.10.0 — 2021-09-27
- 1.9.0 — 2021-08-24
- 1.8.0 — 2021-08-20
- 1.7.0 — 2021-08-09
- 1.6.0 — 2021-02-08
- 1.5.0 — 2020-12-22
- 1.4.0 — 2020-12-21
- … 3 more at https://npm.io/package/@s-ui/react-molecule-avatar/versions

## README

# MoleculeAvatar 👤

The Avatar component is the representation of a user.

[![documentation](https://img.shields.io/badge/read%20the%20doc-black?logo=readthedocs)](https://sui-components.vercel.app/workbench/molecule/avatar/)
[![issue](https://img.shields.io/badge/report%20a%20bug-black?logo=openbugbounty&logoColor=red)](https://github.com/SUI-Components/sui-components/issues/new?&projects=4&template=bug-report.yml&assignees=&template=report-a-bug.yml&title=🪲+&labels=bug,component,molecule,avatar)
[![npm](https://img.shields.io/npm/dt/%40s-ui/react-molecule-avatar?logo=npm&labelColor=black)](https://www.npmjs.com/package/@s-ui/react-molecule-avatar)

[![Issues open](https://img.shields.io/github/issues-search/SUI-Components/sui-components?query=is%3Aopen%20label%3Acomponent%20label%3Aavatar&logo=openbugbounty&logoColor=red&label=issues%20open&color=red)](https://github.com/SUI-Components/sui-components/issues?q=is%3Aopen+label%3Acomponent+label%3Aavatar)
[![NPM](https://img.shields.io/npm/l/%40s-ui%2Freact-molecule-avatar)](https://github.com/SUI-Components/sui-components/blob/main/components/molecule/avatar/LICENSE.md)

## Installation

```sh
$ npm install @s-ui/react-molecule-avatar
```

## Usage

### Basic usage

#### Import package and use the component

```js
import MoleculeAvatar from '@s-ui/react-molecule-avatar'

return <MoleculeAvatar />
```

#### Import the styles (Sass)

```css
@import '~@s-ui/theme/lib/index';
// @import 'your theme';
@import '~@s-ui/react-molecule-avatar/lib/index';
```

### Fallbacks

#### Icon

If no `name` or `src` is set, a default icon will be displayed by default, it can be customized using `fallbackIcon` prop

```jsx
import MoleculeAvatar from '@s-ui/react-molecule-avatar'

const FallbackIconStory = () => (
  <>
    <MoleculeAvatar />
    <MoleculeAvatar fallbackIcon={<Icon />} />
  </>
)
```

#### Name

If `name` is set but `src` is not the initials of the name will be used to generate a accessible background color

```jsx
import MoleculeAvatar from '@s-ui/react-molecule-avatar'

const FallbackNameStory = () => (
  <>
    <MoleculeAvatar name="Jon Snow" />
  </>
)
```

### Size

Modify the size of the avatar with `size` prop. Choose between `xsmall`, `small`, `medium`, `large`, `xlarge` and `xxlarge`

```jsx
import MoleculeAvatar, {AVATAR_SIZES} from '@s-ui/react-molecule-avatar'

const SizeStory = () => (
  <>
    <MoleculeAvatar size={USER_AVATAR_SIZES.XSMALL} />
    <MoleculeAvatar size={USER_AVATAR_SIZES.SMALL} />
    <MoleculeAvatar size={USER_AVATAR_SIZES.MEDIUM} />
    <MoleculeAvatar size={USER_AVATAR_SIZES.LARGE} />
    <MoleculeAvatar size={USER_AVATAR_SIZES.XLARGE} />
    <MoleculeAvatar size={USER_AVATAR_SIZES.XXLARGE} />
  </>
)
```

### Image

If `src` is set an image will be displayed, if it fails one of the fallbacks will be used instead.

```jsx
import MoleculeAvatar from '@s-ui/react-molecule-avatar'

const ImageStory = () => (
  <>
    <MoleculeAvatar name="Jon Snow" src="https://www.images/jon_snow.png" />
  </>
)
```

### Badge

Use `MoleculeAvatar.Badge` component to display a status badge.

```jsx
import MoleculeAvatar from '@s-ui/react-molecule-avatar'

const BadgeStory = () => (
  <>
    <MoleculeAvatar name="Jon Snow">
      <MoleculeAvatar.Badge />
    </MoleculeAvatar>
  </>
)
```

> **Find full description and more examples in the [demo page](#).**

---
_Source: https://npm.io/package/@s-ui/react-molecule-avatar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
