# HasComponent<T>()

> Checks whether a component of type T is attached to this element.

## Definition

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

```csharp
public bool HasComponent<T>() where T : struct, IVisualElementComponent
```

### Returns

| Type                                                          | Description                                             |
| ------------------------------------------------------------- | ------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the component is attached; otherwise `false`. |
