2.0.9 ā€¢ Published 6 months ago

react-metamask-avatar v2.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago
StatementsBranchesFunctionsLines
StatementsBranchesFunctionsLines

react-metamask-avatar

https://img.shields.io/npm/v/react-metamask-avatar https://img.shields.io/github/issues-raw/ssbarbee/react-metamask-avatar https://img.shields.io/npm/dw/react-metamask-avatar

šŸ¤” A React component for rendering MetaMask avatars based on account address

Overview šŸ§

The MetaMaskAvatar component is a React functional component that takes in a required address property of type string and an optional size property of type number. It returns an image avatar of the given Ethereum address provided as a string and renders it within an AvatarWrapper component, which can be styled using the className property.

Demo šŸ˜ˆ

Hosted storybook

Installation šŸ“¦

npm

npm install react-metamask-avatar

yarn

yarn add react-metamask-avatar

Props ā„¹ļø

address

The required address property is a string of length 42 that represents an Ethereum address. If it is not provided or does not meet the expected length, the component returns null.

size

The optional size property is a number that sets the size of the avatar image in pixels. If not provided, it defaults to 24.

className

The optional className property is a string that allows for custom styling using the AvatarWrapper component. It will be added to the className prop of the AvatarWrapper component.

Usage šŸ“š

import React from 'react';
import { MetaMaskAvatar } from 'react-metamask-avatar';

export const App: React.FunctionComponent = () => {
    return (
        <MetaMaskAvatar address="0xb01F14d1C9000D453241221EB54648F1C378c970" size={24} />
    )
}

FAQ šŸ™‹ā“

I want to add custom styling. How can I do that?

Under the hood react-metamask-avatar uses @emotion/styled. Therefore, following a guide for custom styling emotion elements is the way to go.

Example:

import React from 'react';
import { MetaMaskAvatar } from 'react-metamask-avatar';

const SquareMetaMaskAvatar = styled(MetaMaskAvatar)`
    border-radius: none;
`;

export const App: React.FunctionComponent = () => {
    return (
        <SquareMetaMaskAvatar address="0xb01F14d1C9000D453241221EB54648F1C378c970" size={24} />
    )
}
1.6.2

6 months ago

1.6.1

6 months ago

1.6.0

6 months ago

1.5.0

6 months ago

1.4.0

7 months ago

1.3.0

7 months ago

2.0.3

6 months ago

2.0.2

6 months ago

2.0.5

6 months ago

2.0.4

6 months ago

2.0.7

6 months ago

2.0.6

6 months ago

2.0.9

6 months ago

2.0.8

6 months ago

2.0.1

6 months ago

2.0.0

6 months ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago