react-avatar-editor-v1
Version:
A React package that provides an easy-to-use avatar editor along with a customizable avatar display component.
67 lines (44 loc) • 2.05 kB
Markdown
A React package that provides an easy-to-use avatar editor along with a customizable avatar display component.
You can install the package via npm or yarn:
```sh
npm install react-avatar-editor-v1
yarn add react-avatar-editor-v1
```
```tsx
import React, { useState } from 'react';
import ReactAvatarEditor, { ReactNiceAvatar } from 'react-avatar-editor-v1';
import 'react-avatar-editor-v1/dist/main.scss';
const App = () => {
const [config, setConfig] = useState({});
return (
<div>
{/* Display the avatar */}
<ReactNiceAvatar {...config} style={{ width: '10rem', height: '10rem' }} />
{/* Avatar Editor Component */}
<ReactAvatarEditor config={config} setConfig={setConfig} />
</div>
);
};
export default App;
```
| Prop | Type | Description |
| ---------------- | -------------------------------------------- | -------------------------------------------------- |
| `config` | `AvatarFullConfig` | Avatar configuration object. |
| `setConfig` | `Dispatch<SetStateAction<AvatarFullConfig>>` | Function to update the avatar config. |
| `withAvatarList` | `boolean` (default: `true`) | Show/hide additional avatars list. |
This is directly imported from [`react-nice-avatar`](https://github.com/dapi-labs/react-nice-avatar) and can be used to display an avatar based on the `config` state.
Check out the demo GIF to see it in action:

The `ReactNiceAvatar` component renders the avatar based on the provided configuration, while `ReactAvatarEditor` allows users to modify the avatar features in real time.
This project is licensed under the MIT License.