# ToolbarPanel

> Represents a navigable group of metrics in the debug toolbar.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Toolbar](/docs/extensions/debug-core/reference/toolbar/index.md) › ToolbarPanel

| final readonly class | `PHPForge\Debug\Toolbar\ToolbarPanel` |
| --- | --- |
| Implements | [`JsonSerializable`](https://www.php.net/manual/en/class.jsonserializable.php) |
| Source | [`src/Toolbar/ToolbarPanel.php`](https://github.com/php-forge/debug-core/blob/main/src/Toolbar/ToolbarPanel.php#L15) |

Represents a navigable group of metrics in the debug toolbar.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-extension"></span>`$extension` readonly constructor | `bool` | `true` when the panel is provider-owned or optional and the toolbar groups it under its Extensions menu; `false` when the panel is built in and stays inline. Default: `false`. | `ToolbarPanel` |
| <span id="property-icon"></span>`$icon` readonly constructor | `string\|null` | Shared icon name or `null` when no icon is available. Default: `null`. | `ToolbarPanel` |
| <span id="property-id"></span>`$id` readonly constructor | `string` | Stable panel identifier. | `ToolbarPanel` |
| <span id="property-items"></span>`$items` readonly constructor | `list<`[`ToolbarItem`](/docs/extensions/debug-core/reference/toolbar/toolbaritem/index.md)`>` | Panel metrics. Default: `[]`. | `ToolbarPanel` |
| <span id="property-title"></span>`$title` readonly constructor | `string` | Display title. | `ToolbarPanel` |
| <span id="property-url"></span>`$url` readonly constructor | `string\|null` | Debug page URL or `null` when only individual metrics are navigable. Default: `null`. | `ToolbarPanel` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`create()`](#method-create) static | Creates a panel with no metrics or optional navigation. | `ToolbarPanel` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the panel payload consumed by the toolbar runtime. | `ToolbarPanel` |
| [`withExtension()`](#method-withExtension) | Returns a copy with the specified extension classification. | `ToolbarPanel` |
| [`withIcon()`](#method-withIcon) | Returns a copy with the specified icon. | `ToolbarPanel` |
| [`withItems()`](#method-withItems) | Returns a copy with the replacement metric list. | `ToolbarPanel` |
| [`withUrl()`](#method-withUrl) | Returns a copy with the specified URL. | `ToolbarPanel` |

## Method details

### create() <span id="method-create"></span>

```php
public static function create(string $id, string $title): self
```

Creates a panel with no metrics or optional navigation.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `string` | Stable panel identifier. |
| `$title` | `string` | Display title. |

**Returns**

`self`: Panel carrying only its identity.

### jsonSerialize() <span id="method-jsonSerialize"></span>

```php
public function jsonSerialize(): array{id: string, title: string, items: list<array{value: string, status: string, label?: string, icon?: string, title?: string, url?: string, id?: string}>, url?: string, icon?: string, extension?: true}
```

Returns the panel payload consumed by the toolbar runtime.

**Returns**

`array{id: string, title: string, items: list<array{value: string, status: string, label?: string, icon?: string, title?: string, url?: string, id?: string}>, url?: string, icon?: string, extension?: true}`: Serialized panel payload.

### withExtension() <span id="method-withExtension"></span>

```php
public function withExtension(bool $extension): self
```

Returns a copy with the specified extension classification.

An extension panel is provider-owned or optional, so the toolbar groups it under its Extensions menu, while
built-in panels stay inline.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$extension` | `bool` | `true` to group the panel under the Extensions menu; `false` to keep it inline. |

**Returns**

`self`: Panel with the classification applied.

### withIcon() <span id="method-withIcon"></span>

```php
public function withIcon(string|null $icon): self
```

Returns a copy with the specified icon.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$icon` | `string\|null` | Shared icon name, or `null` when no icon is available. |

**Returns**

`self`: Panel with the icon applied.

### withItems() <span id="method-withItems"></span>

```php
public function withItems(list<PHPForge\Debug\Toolbar\ToolbarItem> $items): self
```

Returns a copy with the replacement metric list.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$items` | `list<`[`ToolbarItem`](/docs/extensions/debug-core/reference/toolbar/toolbaritem/index.md)`>` | Panel metrics in display order; `[]` removes all metrics. |

**Returns**

`self`: Panel with the metrics applied.

### withUrl() <span id="method-withUrl"></span>

```php
public function withUrl(string|null $url): self
```

Returns a copy with the specified URL.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$url` | `string\|null` | Debug page URL, or `null` when only individual metrics are navigable. |

**Returns**

`self`: Panel with the URL applied.