1.1.2 • Published 1 year ago

@zamplyy/react-native-nice-avatar v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-nice-avatar

Version npm download

React Nice avatars but for React Native 📱

Credits

This package is basically a fork from react-nice-avatar, but intended for React Native.

Known issues

isGradient prop isn't working see #12

Installation

npm install @zamplyy/react-native-nice-avatar

or

(recommended)

yarn add @zamplyy/react-native-nice-avatar

Usage

  1. Import the component.
    import Avatar, { genConfig } from '@zamplyy/react-native-nice-avatar';
  2. Generate a random configuration, save it so that you can always rendering a same avatar with the configuration.

    const config = genConfig(AvatarConfig?)

    tip: AvatarConfig is an Object, please check the Options below for what attributes can be passed in

  3. Render the component with specific width / height and configuration.

    <Avatar style={{ width: 50, height: 50 }} {...config} />

    or

    <Avatar size={50} {...config} />

Options

The options can be passed into genConfig or as React props

keytypedefaultaccepttips
styleViewStyleOnly for React Props
sizenumberOnly for React Props
shapestringcirclecircle, rounded, squareOnly for React Props
sexstringman, woman
faceColorstring
earSizestringsmall, big
hairColorstring
hairStylestringnormal, thick, mohawk, womanLong, womanShort
hairColorRandombooleanfalsethick,mohawk default only be black
hatColorstring
hatStylestringnone, beanie, turbanUsually is none
eyeStylestringcircle, oval, smile
glassesStylestringnone, round, squareUsually is none
noseStylestringshort, long, round
mouthStylestringlaugh, smile, peace
shirtStylestringhoody, short, polo
shirtColorstring
bgColorstring
isGradientbooleanfalse

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Assets