Giter Site home page Giter Site logo

ayhoung / react-user-avatar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wbinnssmith/react-user-avatar

0.0 1.0 0.0 22 KB

React component for a user avatar with fallback to colored initials

License: MIT License

CSS 8.65% JavaScript 91.35%

react-user-avatar's Introduction

React UserAvatar

A bare-bones user avatar display with support for falling back to using the user's initials on a colored background as the avatar.

Installation

npm install -S react-user-avatar

Usage

  <UserAvatar size="48" name="Will Binns-Smith" />
  <UserAvatar size="48" name="Will Binns-Smith" src="https://pbs.twimg.com/profile_images/429442426038538240/6Ac9kykG_400x400.jpeg" />
  <UserAvatar size="48" name="John Doe" colors={['#ccc', '#fafafa', '#ccaabb']}/>
  <UserAvatar size="48" name="Mary Ann Gilligans" />
  <UserAvatar size="48" name="Jane Doe" color="#FFF" />
  <UserAvatar size="48" name="Madonna" />

This module uses react-style inline styles to narrow the api, yet allows for reasonable extensibility by exposing a number of DOM classes. Take a look (or simply use) example.css for ideas.

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

If the component determines that the color chosen was visually light, it will apply a UserAvatar--light class to the root element. If the color chosen was dark, it will apply UserAvatar--dark. Take advantage of these to use the appropriately colored text or border when styling the component.

react-user-avatar's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.