# GetComponent<T>()

> Returns a reference to the attached component of type T.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.UIElements](/engine/6000.7/script-reference/unityengine/uielements.md)
* **Assembly:** UnityEngine.UIElementsModule

```csharp
public ref T GetComponent<T>() where T : struct, IVisualElementComponent
```

### Returns

| Type | Description                             |
| ---- | --------------------------------------- |
| T    | A reference to the live component data. |

### Remarks

The reference points at the component's live storage: assigning to its fields updates the element directly, with no need to write the value back. The reference stays valid until the component is removed.
