1.0.4 • Published 2 years ago

react-hooks-identicons v1.0.4

Weekly downloads
79
License
ISC
Repository
github
Last release
2 years ago

header

React Hooks Identicons

A dynamic React component that creates an identicon based on a provided string. This library is based on react-identicons but was rewritten in React Hooks to avoid deprecation warnings.

Install

With npm:

npm i --save react-hooks-identicons

With yarn:

yarn add react-hooks-identicons

Usage

import React from 'react';
import Identicon from 'react-hooks-identicons';

const App = () => {
    return (
        <Identicon string='user@example.com' />
    );
};

export default App;

API

The following props are available:

PropTypeDescription
stringstringIs used to generate the identicon.
sizeintegerDefines the width and height of the identicon.
paddingintegerAdds padding in px to the blocks.
bgstringBackground color.
fgstringColor of the blocks. If no color was provided, it generates the color based on the string.
palettestringArray of hex color strings that will be used as color for the blocks.
countnumberNumber of blocks. Allowed counts are 1-5.
getColorfunctionThe color for the blocks will be passed to the getColor function, if it was provided.

Only the string prop is mandatory. All other props are optional.

Credits

This library is based on the concept of react-identicons.