# ComponentElement

Class · extends [`AsyncElement`](https://api.playcanvas.com/web-components/classes/AsyncElement.md) · category: Base Classes

Source: https://github.com/playcanvas/web-components/blob/252f001881302c266c8d727044408c32be2bb5e7/src/components/component.ts#L13

Represents a component in the PlayCanvas engine.

## Accessors

### component

```ts
get component(): T | null
```

The PlayCanvas component instance. `null` until the element is ready, and also for an
element that is not a descendant of an entity-fronting element (`<pc-entity>`,
`<pc-model>` or `<pc-node>`) — await [whenReady](https://api.playcanvas.com/web-components/functions/whenReady.md) or the element's `ready()` promise
before accessing it.

### enabled

```ts
get enabled(): boolean
set enabled(value: boolean)
```

Gets the enabled state of the component.

## Methods

### getInitialComponentData

```ts
protected getInitialComponentData(): {}
```

Returns the data the component is created with. Overridden by subclasses to supply the
initial values of their cached properties. The element's `enabled` state is not among them:
the base class adds it when it creates the component.

**Returns** `{}`: The initial component data.

### initComponent

```ts
protected initComponent(): void
```

Configures the newly added component. Overridden by subclasses whose setup goes beyond
the initial data — child-element handling, asset resolution and the like.

## Inherited from [AsyncElement](https://api.playcanvas.com/web-components/classes/AsyncElement.md)

- `get closestApp(): AppElement | null`
- `get closestEntity(): EntityBaseElement | null`
- `protected _onReady(): void`
- `protected _resetReady(): void`
- `ready(): Promise<ComponentElement<T>>`
