---
title: "Custom tools in MAUI PDF viewer"
canonical_url: "https://www.nutrient.io/guides/maui/user-interface/main-toolbar/create-a-new-tool/"
md_url: "https://www.nutrient.io/guides/maui/user-interface/main-toolbar/create-a-new-tool.md"
last_updated: "2026-06-09T10:30:03.954Z"
description: "Learn how to add custom tools to the MAUI PDF viewer toolbar and enhance your workflow with user-defined items and control options."
---

# Create custom tools for MAUI PDF viewer

The main differentiator between built-in toolbar items and user-defined ones is the `Id`, which is used to explicitly identify the latter. You can add one of the built-in types or a custom toolbar item of type [`CustomMainToolbarItem`](https://www.nutrient.io/api/maui/api/PSPDFKit.Api.Toolbar.ICustomMainToolbarItem.html), [`CustomMainToolbarButton`](https://www.nutrient.io/api/maui/api/PSPDFKit.Api.Toolbar.ICustomMainToolbarButton.html), or [`CustomMainToolbarToggleButton`](https://www.nutrient.io/api/maui/sdk/PSPDFKit.Sdk.Models.Toolbar.MainToolbarItems.CustomMainToolbarToggleButton.html) to the main toolbar. All these types are subclasses of [`MainToolbarItems`]:

```csharp

using static PSPDFKit.Sdk.Models.Toolbar.MainToolbarItems;...

var toolbarItem = new CustomMainToolbarItem("customItemId");

var toolbarButton = new CustomMainToolbarButton("customButtonId")
{
    Icon = "newIcon.svg",
    Tooltip = "My button",
};
toolbarButton.Clicked += (s, e) => Debug.WriteLine("My button clicked");

var toolbarToggleButton = new CustomMainToolbarToggleButton("customToggleButtonId")
{
    Icon = "newIcon.svg",
    Tooltip = "My button",
    IsSelected = true,
};
toolbarToggleButton.Clicked +=
  (s, e) => Debug.WriteLine("My toggle button clicked");

```

When the `Icon` for a button is missing, the `Tooltip` will instead be displayed as `Button.Text`. This is useful if you want to create text-only buttons.

The `Clicked` event is invoked when a button is either clicked or tapped (on touch devices).

Once the custom button is ready, it’s possible to insert it into the current list:

```csharp

PSPDFKitController.MainToolbar.ToolbarItems.Add(toolbarItem)
PSPDFKitController.MainToolbar.ToolbarItems.Add(toolbarButton)
PSPDFKitController.MainToolbar.ToolbarItems.Add(toolbarToggleButton)

```

## Control item visibility via MediaQueries

Each toolbar item’s visibility is controlled by its `MediaQueries` property. When `MediaQueries` isn’t defined, the item will always be visible.

`MediaQueries` is an observable collection of [valid CSS media query](https://www.nutrient.io/api/web/NutrientViewer.ToolbarItem.html#mediaQueries) strings.

Additionally, built-in items have extra internal logic that, under some circumstances, removes them from the list.

## Toolbar layout and the spacer item

The items list is rendered as a flat list of sibling elements that are separated by a special toolbar item called `SpacerItem`. This solution makes the toolbar layout flexible and easy to customize.

The `SpacerItem` is an empty element, and it pushes items from both sides together, making them more compact. You can insert as many `SpacerItem`s as you want.
---

## Related pages

- [Activate or deactivate tools in our viewer toolbar](/guides/maui/user-interface/main-toolbar/activate-or-deactivate-tools.md)
- [Customizing existing tools in our viewer toolbar](/guides/maui/user-interface/main-toolbar/customize-existing-tools.md)
- [Customizing download/export buttons in our PDF viewer](/guides/maui/user-interface/main-toolbar/download-export-button.md)
- [Customizing the dropdown navigation in our viewer toolbar](/guides/maui/user-interface/main-toolbar/dropdown-groups.md)
- [Hiding the toolbar in our PDF viewer](/guides/maui/user-interface/main-toolbar/hide-the-toolbar.md)
- [Adding page labels to navigation in our viewer](/guides/maui/user-interface/main-toolbar/page-label-navigation.md)
- [Adjust the placement of the toolbar in our viewer](/guides/maui/user-interface/main-toolbar/placement.md)
- [Rearrange tools in our viewer toolbar](/guides/maui/user-interface/main-toolbar/rearrange.md)
- [Removing a tool from the toolbar in our MAUI viewer](/guides/maui/user-interface/main-toolbar/remove-a-tool.md)
- [Customizing responsive navigation in our viewer toolbar](/guides/maui/user-interface/main-toolbar/responsive-groups.md)

