# Descendents

> Selects all elements, recursively, that are descendants of currently matching ancestors.

## Definition

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

## Descendents\<T>(string, string\[])

Selects all elements, recursively, that are descendants of currently matching ancestors.

```csharp
public UQueryBuilder<T2> Descendents<T2>(string name = null, params string[] classNames) where T2 : VisualElement
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): **** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)):&#x20;

### Returns

| Type                                                                                          | Description |
| --------------------------------------------------------------------------------------------- | ----------- |
| [UQueryBuilder\<T>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) |             |

### Examples

```csharp
// Get all children, recursively, of root that are buttons and have classes "health-button" or "unity-button".
var buttons = root.Query().Descendents<Button>(classNames: new[] { "health-button", "unity-button" });
```

## Descendents\<T>(string, string)

Selects all elements, recursively, that are descendants of currently matching ancestors.

```csharp
public UQueryBuilder<T2> Descendents<T2>(string name = null, string classname = null) where T2 : VisualElement
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): **** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)):&#x20;

### Returns

| Type                                                                                          | Description |
| --------------------------------------------------------------------------------------------- | ----------- |
| [UQueryBuilder\<T>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) |             |

### Examples

```csharp
// Get all children, recursively, of root that are buttons and have class "health-button".
var buttons = root.Query().Descendents<Button>(classname: "health-button");
```

## Descendents\<T>(UniqueStyleString)

Selects all elements, recursively, that are descendants of currently matching ancestors.

```csharp
public UQueryBuilder<T2> Descendents<T2>(UniqueStyleString classname) where T2 : VisualElement
```

### Parameters

**** (\[UniqueStyleString]\(/engine/6000.6/script-reference/unityengine/uielements/uniquestylestring)):&#x20;

### Returns

| Type                                                                                          | Description |
| --------------------------------------------------------------------------------------------- | ----------- |
| [UQueryBuilder\<T>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) |             |

### Examples

```csharp
// Get all children, recursively, of root that are buttons and have class "health-button".
var buttons = root.Query().Descendents<Button>(classname: "health-button");
```

## Descendents\<T>(string, UniqueStyleString)

Selects all elements, recursively, that are descendants of currently matching ancestors.

```csharp
public UQueryBuilder<T2> Descendents<T2>(string name, UniqueStyleString classname) where T2 : VisualElement
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): **** (\[UniqueStyleString]\(/engine/6000.6/script-reference/unityengine/uielements/uniquestylestring)):&#x20;

### Returns

| Type                                                                                          | Description |
| --------------------------------------------------------------------------------------------- | ----------- |
| [UQueryBuilder\<T>](/engine/6000.6/script-reference/unityengine/uielements/uquerybuilder1.md) |             |

### Examples

```csharp
// Get all children, recursively, of root that are buttons and have class "health-button".
var buttons = root.Query().Descendents<Button>(classname: "health-button");
```
