# ToolbarItems

## Content

# Interface: ToolbarItems

## Properties

### addItem

```ts
addItem: (item) => void;
```

Adds a new item to the toolbar.

#### Parameters

##### item

[`ToolbarItem`](ToolbarItem)

An item to be added.

#### Returns

`void`

#### Example

```javascript
var pdfExportButton = {
    key: '$pdfExportButtonKey',
    iconCssClass: 'mdi mdi-file-pdf',
    enabled: true,
    action: function(item) {
        console.log('Export to PDF function works here');
    },
    onUpdate: function(arg, item) {
        console.log('Something in viewer was updated, check/update button state here');
    }
};
viewer.toolbar.desktop.addItem(pdfExportButton);
```

***

### getKeys

```ts
getKeys: () => string[];
```

Returns identifiers of default and added buttons in the order in which they will be displayed in the toolbar.

#### Returns

`string`[]

#### Example

```javascript
viewer.toolbar.desktop.layout(viewer.toolbar.desktop.getKeys().reverse())
```

***

### layout

```ts
layout: (keys) => void;
```

Sets the keys of the visible toolbar items and their order.

#### Parameters

##### keys

`string`[]

The array of the keys of toolbar items to be visible on toolbar in the desired order.

#### Returns

`void`

#### Example

```javascript
viewer.toolbar.desktop.addItem(pdfExportButton);
// now you want to remove everything except pdfExportButton and the navigation block.
viewer.toolbar.desktop.layout(['$pdfExportButtonKey', '$navigation']);
```
will create a toolbar with the export button and the "navigation" block.

***

### removeItem

```ts
removeItem: (key) => void;
```

Removes existing item from the toolbar.

#### Parameters

##### key

`string`

The toolbar item key, as it was specified in the addItem parameters.

#### Returns

`void`

#### Example

```javascript
viewer.toolbar.desktop.removeItem(pdfExportButton);
```

***

### updateItem

```ts
updateItem: (key, itemUpdate) => void;
```

Updates a previously added toolbar item.

#### Parameters

##### key

`string`

the toolbar item key, as it was specified in the addItem parameters.

##### itemUpdate

[`ToolbarItem`](ToolbarItem)

New toolbar item settings.

#### Returns

`void`
