Socket
Socket
Sign inDemoInstall

@s-ui/react-molecule-avatar

Package Overview
Dependencies
8
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @s-ui/react-molecule-avatar

The Avatar component is the representation of a user.


Version published
Weekly downloads
1K
increased by11.58%
Maintainers
1
Install size
258 kB
Created
Weekly downloads
 

Readme

Source

MoleculeAvatar 👤

The Avatar component is the representation of a user.

Installation

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

Usage

Basic usage

Import package and use the component
import MoleculeAvatar from '@s-ui/react-molecule-avatar'

return <MoleculeAvatar />
Import the styles (Sass)
@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

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

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

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.

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.

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.

FAQs

Last updated on 17 Oct 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc