1.0.2 • Published 5 years ago

pravatar v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Pravatar

Avatar Placeholder

NPM JavaScript Style Guide

React pravatar component preview

For the moment we support following types:

  • Any String
  • Custom image
  • Name initials

Install

npm install --save pravatar

# besides React, react-avatar also has prop-types as peer dependency,
# make sure to install it into your project
$ npm install prop-types --save

Usage

import React, { Component } from "react";

import Pravatar from "pravatar";

class Example extends Component {
  render() {
    return (
      <Pravatar
        text=""
        image="https://avatars1.githubusercontent.com/u/17858766?s=88&v=4"
        width="100px"
        height="100px"
        radius="100px"
        fontSize="50px"
        bg="#e7e7e7"
        textColor="#000"
        border="1px solid black"
        position="center"
        size="cover"
        weight="bold"
      />
    );
  }
}

Options

Avatar

AttributeOptionsDefaultDescription
textstringemptyAny String
imagestringemptyImage avatar to use
textColorstringinheritset the color of text
sizestringcoverset the background image size
positionstringcenterset the background image position
weightstringnormalset the font weight
fontSizestringinheritset the font size
borderstringnoneset the border of the avatar
radiusstring100pxset the border radius of the avatar
heightstring50pxset the height of the avatar
widthstring50pxset the width of the avatar
bgstringinheritTo set the background color of the avatar
initialbooleanfalseWill be used to generate avatar based on the initials of the person

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT License