# Children

> Selects all direct child elements of elements matching the previous rules.

## Definition

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

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

Selects all direct child elements of elements matching the previous rules.

```csharp
public UQueryBuilder<T2> Children<T2>(string name = null, params string[] classes) 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.7/script-reference/unityengine/uielements/uquerybuilder1.md) |             |

### Examples

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

## Children\<T>(string, UniqueStyleString\[])

Selects all direct child elements of elements matching the previous rules.

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

### Parameters

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

### Returns

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

### Examples

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

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

Selects all direct child elements of elements matching the previous rules.

```csharp
public UQueryBuilder<T2> Children<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.7/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().Children<Button>(className: "health-button");
```

## Children\<T>(UniqueStyleString)

Selects all direct child elements of elements matching the previous rules.

```csharp
public UQueryBuilder<T2> Children<T2>(UniqueStyleString className) where T2 : VisualElement
```

### Parameters

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

### Returns

| Type                                                                                          | Description |
| --------------------------------------------------------------------------------------------- | ----------- |
| [UQueryBuilder\<T>](/engine/6000.7/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().Children<Button>(className: "health-button");
```

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

Selects all direct child elements of elements matching the previous rules.

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

### Parameters

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

### Returns

| Type                                                                                          | Description |
| --------------------------------------------------------------------------------------------- | ----------- |
| [UQueryBuilder\<T>](/engine/6000.7/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().Children<Button>(className: "health-button");
```
