# Blazor PanelBar Overview

The <a href="https://www.telerik.com/blazor-ui/panelbar" target="_blank">Blazor PanelBar component</a> displays [data](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/overview) ([flat](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/flat-data) or [hierarchical](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/hierarchical-data)) in an accordion type structure. In addition to built-in [navigation capabilities](https://www.telerik.com/blazor-ui/documentation/components/panelbar/navigation), you can navigate through the items and their children, define [templates](https://www.telerik.com/blazor-ui/documentation/components/panelbar/templates/overview), render text and [icons/images](https://www.telerik.com/blazor-ui/documentation/components/panelbar/icons), and respond to [events](https://www.telerik.com/blazor-ui/documentation/components/panelbar/events).

## Comparison with ExpansionPanel

The [ExpansionPanel](https://www.telerik.com/blazor-ui/documentation/components/expansionpanel/overview) and PanelBar are similar and interchangeable in some aspects. The major differences between the two components are:

* The PanelBar is a [databound component](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/overview). The ExpansionPanel and its content are [defined declaratively](https://www.telerik.com/blazor-ui/documentation/components/expansionpanel/overview#creating-blazor-expansionpanel).
* When using a hierarchy of parent and child items, the PanelBar uses different styling for the children, while the nested ExpansionPanel instances look in the same way as their parent.
* The PanelBar provides built-in selection and [navigation](https://www.telerik.com/blazor-ui/documentation/components/panelbar/navigation), while the ExpansionPanel does not.
* The ExpansionPanel is more convenient to use in scenarios where multiple instances one below the other show very different content that cannot be generalized in a single [PanelBar `ContentTemplate`](https://www.telerik.com/blazor-ui/documentation/components/panelbar/templates/content).

## Creating Blazor PanelBar

1. Add the `TelerikPanelBar` tag
2. Populate the `Data` property with the collection of items that you want to appear in the PanelBar. The component will automatically recognize property names like `Id`, `ParentId`, `Text` and a few others. Otherwise, [use bindings to configure custom property names](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/overview#data-bindings).

> caption Basic PanelBar with hierarchical data binding

<demo metaUrl="client/panelbar/overview/" height="420"></demo>

## Data Binding

To show any items, the Blazor PanelBar requires a data source that you can provide through the `Data` property. The PanelBar allows you to display the items both as flat data and hierarchically. [Read more about the Blazor PanelBar data binding...](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/overview)

## Elements of a PanelBar Item

Each item in the PanelBar consists of a `Header` and `Content`. The image below illustrates the concept.

The `Header` contains the Text of the corresponding data item (model). The `Content` represents the items in the hierarchy that do not have children.

![panelbar parts](https://www.telerik.com/blazor-ui/documentation/assets/54812bbdbef0c8688a085835824a2c05/panelbar-parts-overview.png)

## Templates

The PanelBar allows customizing of its item elements. Use [Header Template](https://www.telerik.com/blazor-ui/documentation/components/panelbar/templates/header) and [Content Template](https://www.telerik.com/blazor-ui/documentation/components/panelbar/templates/content) to override the default rendering. A `ContentTemplate` displays like a child item. It is rendered only for the items, which have no children.

## Navigation

The PanelBar can be used to navigate between different pages in the application. [Read more about the Blazor PanelBar navigation...](https://www.telerik.com/blazor-ui/documentation/components/panelbar/navigation)

## Icons

To illustrate the purpose of each item, the Blazor PanelBar allows you to add images, icon classes, or font icons. [Read more about the Blazor PanelBar icons...](https://www.telerik.com/blazor-ui/documentation/components/panelbar/icons)

## Events

The Blazor PanelBar generates events that you can handle to respond to the user action. [Read more about the Blazor PanelBar events...](https://www.telerik.com/blazor-ui/documentation/components/panelbar/events)

## PanelBar Parameters

The following table lists PanelBar parameters, which are not related to other features on this page. Check the [PanelBar API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikpanelbar) for a full list of properties, methods and events.

<style>
    .article table {
        table-layout: auto;
        word-break: normal;
    }
</style>

| Parameter       | Type and Default Value                                          | Description                                                                                                                                                                                                              |
| --------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Class`         | `string`                                                        | The CSS class that will be rendered on the main wrapping element of the component.                                                                                                                                       |
| `ExpandedItems` | `IEnumerable<Object>`                                           | A collection of the expanded PanelBar items. Supports two-way binding. Read more in the [ExpandedItems](https://www.telerik.com/blazor-ui/documentation/components/panelbar/expanded-items) article.                     |
| `ExpandMode`    | `PanelBarExpandMode` enum <br/> (`PanelBarExpandMode.Multiple`) | Whether the PanelBar will allow single or multiple items to be expanded at a time. Read more in the [ExpandMode](https://www.telerik.com/blazor-ui/documentation/components/panelbar/expanded-items#expandmode) section. |

## PanelBar Reference and Methods

To execute PanelBar methods, obtain reference to the component instance via `@ref`.

The PanelBar is a generic component. Its type depends on the type of its model and the type of its `Value`. In case you cannot provide either the `Value` or `Data` initially, you need to [set the corresponding types to the `TItem` and `TValue` parameters](https://www.telerik.com/blazor-ui/documentation/common-features/data-binding/overview#component-type).

The table below lists the PanelBar methods. Also consult the [PanelBar API](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikpanelbar).

| Method   | Description                                                                                                                     |
| -------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `Rebind` | [Refreshes the component data](https://www.telerik.com/blazor-ui/documentation/components/panelbar/refresh-data#rebind-method). |

```RAZOR.skip-repl
<TelerikPanelBar @ref="@PanelBarRef" .../>

@code{
    private TelerikPanelBar PanelBarRef;
}
```

## Next Steps

* [Binding PanelBar PanelBar to Data](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/overview)
* [Using the PanelBar to Navigate between Pages](https://www.telerik.com/blazor-ui/documentation/components/panelbar/navigation)

## See Also

* [Data Binding a PanelBar](https://www.telerik.com/blazor-ui/documentation/components/panelbar/data-binding/overview)
* [Live Demo: PanelBar](https://demos.telerik.com/blazor-ui/panelbar/overview)
* [PanelBar API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikpanelbar)
