1.0.9 • Published 5 years ago
react-robohash v1.0.9
Install
npm install react-robohash --save
# or
yarn add react-robohash
Playground
You can play around with the module on codesandbox
Props
Name | Type | Required | Default | Description | |
---|---|---|---|---|---|
name | string | true | name, email, whatever identifier you want | ||
alt | string | false | Robohash-${name} | alt property for image | |
className | string | false | Robohash | pass custom class | |
size | string | number | false | specify image size like 200 or 100x50 (square works best) | |
type | string | number | false | robot | type - "robot", "alien", "head", "cat", 1, 2, 3, 4 |
background | string | false | 0 | custom background set (1, 2) | |
fileType | string | false | png | image return type, png, svg, jpg (see homepage) | |
gravatar | boolean | false | false | checks if gravatar is available otherwise fallbacks to robot | |
children | function | false | custom render prop function which gets only the url passed in (see example) |
Usage
import Robohash from 'react-robohash';
<Robohash
name="foxy"
type="cat"
/>
or with custom element as render prop function
import Robohash from 'react-robohash';
<Robohash name="react-robohash">
{url => <span>{url}</span>}
</Robohash>
Author
- Felix Wostal @felixwostal
Support
If you like the project and want to support my work, you can think about buy me a coffee :)