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

react-native-user-avatar

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-user-avatar

React Native component for a user avatar with fallback to colored initials

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1K
decreased by-10.26%
Maintainers
1
Weekly downloads
 
Created
Source

React Native User Avatar

npm version npm downloads Build Status

Coverage lines Coverage functions Coverage branches Coverage statements

A bare-bones user avatar display with support for falling back to using the user's initials on a colored background as the avatar. Based on the great library for React: https://github.com/wbinnssmith/react-user-avatar, and ported to React Native.

iOS ScreenshotAndroid Screenshot

Installation

npm install --save react-native-user-avatar or yarn add react-native-user-avatar

Usage

The fallback avatar's color may be set by passing in the bgColor prop, or you can customize the range of colors used by passing in an array of bgColors. The component uses a simple calculation to consistently use the same color for the same user's name every time.

UserAvatar Component

import UserAvatar from 'react-native-user-avatar';

const App: () => React$Node = () => {
  return (
    <>
    ...
    <View>
      <UserAvatar size={100} name="Avishay Bar" />
      <UserAvatar size={100} name="Avishay Bar" src="https://dummyimage.com/100x100/000/fff" />
      <UserAvatar size={50} name="John Doe" bgColors={['#ccc', '#fafafa', '#ccaabb']}/>
      <UserAvatar size={50} name="John Doe" />
      <UserAvatar size={50} name="Jane Doe" bgColor="#000" />
    </View>
    ...

UserAvatar Props

AttributeTypeDefault ValueDescription
namestring'John Doe'name used for generating initials
srcstringundefinedsource image on the internet to display
bgColorstringundefinedcustom background color for the initials
bgColorsarraysee index.jscustom array of background colors to choose from
textColorstring'#fff'custom text color for the initials font
sizenumber32custom size that defines both the avatar and the initials font size
imageStyleobjectundefinedcustom image styling to append to the Image component displays the source image
textStyleobjectundefinedcustom text styling to append to the Text component that displays initials
styleobjectundefinedcustom style to append to the UserAvatar component container
borderRadiusnumbersize * 0.5custom border radius for the component
componentReact.Componentundefinedcustom component to display instead of initials or source image

Contributing

Contributions are welcome. Please see CONTRIBUTING.md if you like to contribute to this library.

Credits

@wbinnssmith for creating https://github.com/wbinnssmith/react-user-avatar

License

MIT

Keywords

FAQs

Package last updated on 30 Dec 2021

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