# Function: add() (/jsdoc/pixi-vn/index/namespaces/RegisteredCanvasComponents/functions/add)



\> **add**\<`M`, `T`>(`target`, `options?`): `void`

Defined in: [src/canvas/decorators/canvas-element-decorator.ts:150](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/canvas/decorators/canvas-element-decorator.ts#L150)

Register a canvas component in the game.

Type Parameters [#type-parameters]

M [#m]

`M` *extends* [`CanvasBaseItemMemory`](/jsdoc/pixi-vn/index/interfaces/CanvasBaseItemMemory)

T [#t]

`T` *extends* *typeof* [`CanvasBaseItem`](/jsdoc/pixi-vn/index/classes/CanvasBaseItem)

Parameters [#parameters]

target [#target]

`T`

The class of the canvas component.

options? [#options]

Options for the canvas component.

copyProperty? [#copyproperty]

(`component`, `memory`) => `void` | `Promise`\<`void`>

Function to copy the properties of the canvas component. This function is used when to copy the properties of the canvas component into another instance of the same canvas component.
This function is used into [canvas.copyCanvasElementProperty](/jsdoc/pixi-vn/index/interfaces/CanvasManagerInterface#copycanvaselementproperty) to copy the properties of the canvas component.

getInstance? [#getinstance]

(`canvasClass`, `memory`) => [`CanvasBaseItem`](/jsdoc/pixi-vn/index/classes/CanvasBaseItem)\<`M`> | `Promise`\<[`CanvasBaseItem`](/jsdoc/pixi-vn/index/classes/CanvasBaseItem)\<`M`>>

Function to get the instance of the canvas component. If not set, it will use the default constructor of the class.
This function is used into [canvas.restore](/jsdoc/pixi-vn/index/interfaces/CanvasManagerInterface#restore) to restore the canvas.

name? [#name]

`string`

Name of the canvas component. If the name is already registered, it will show a warning

**Default**

```ts
target.name
```

Returns [#returns]

`void`
