Skip to main content

users

Description

Optional. Provides a list of users that can be associated with comments

Usage

users?: {
id: string | number;
name?: string;
avatar?: string;
color?: string;
}[];

Parameters

  • id - (required) unique identifier of the user
  • name - (optional) displays the name of a user
  • avatar - (optional) URL of the user's avatar image
  • color - (optional) the color used for styling the user's comments

Example

Initializing comments widget with data and list of users:

import { useState } from "react";
import { Comments } from "@svar-ui/react-comments";

export default function App() {
const [value, setValue] = useState([
{
id: "1",
content: "Hello, world!",
user: 1,
date: new Date(),
},
]);

const users: {
id: number | string;
name?: string;
avatar?: string;
color?: string;
}[] = [
{ id: 1, name: "John Doe" },
{ id: 2, name: "Jane Doe" },
];

return <Comments value={value} users={users} />;
}