Overview

The Toolbar component allows you to implement an adaptive button-based interface within your Blazor application. Toolbar buttons are stored in the Items collection, and each button is defined by a DxToolbarItem object (which can display an icon, text or both).

Key Toolbar API members are as follows:

  • Click — Fires when users click the toolbar item. Handle this event to specify different click handlers for different items. To specify a common click handler for all toolbar items, use the Toolbar's ItemClick event.
  • Text — Specifies item text.
  • BeginGroup — Set to true to create a new item group.
  • IconCssClass — Specifies the name of the CSS class applied to a toolbar item's icon.
  • NavigateUrl — Specifies the item's navigation URL. When this property is specified, the button is rendered as a hyperlink.
  • Target — Specifies target attribute value for an item.
  • Alignment — Specifies item alignment.
  • Enabled — Specifies whether the component is enabled.

The Toolbar component also supports keyboard navigation. Press the Tab key or Shift+Tab to focus the toolbar and use Arrow keys to navigate through menu items.

 Data Binding

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet metus vel nisi blandit tincidunt vel efficitur purus. Nunc nec turpis tempus, accumsan orci auctor, imperdiet mauris. Fusce id purus magna.

You can populate the Toolbar component with data from a flat or hierarchical data source. This demo demonstrates how to bind the component to a flat data item collection. Associated code performs the following:

If the data source uses flat data, Key and ParentKey properties are required. For hierarchical data, the Children property is required.

 Drop-Down Items

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet metus vel nisi blandit tincidunt vel efficitur purus. Nunc nec turpis tempus, accumsan orci auctor, imperdiet mauris. Fusce id purus magna.

A toolbar item displays a drop-down list if you populate the DxToolbarItem.Items collection. The drop-down list can be displayed as a standard sub-menu, as a modal dialog, or as a modal bottom sheet. You can specify its type explicitly or allow the component to adapt to the device type. To specify the display mode, use the following properties:

You can turn a parent toolbar item into a split button (where its drop-down action is segregated from the primary click region). To enable this behavior, set the SplitDropDownButton property to true.

 Render Style

You can use the following API members to customize the appearance of the Toolbar's root-level items:

 Checked Items and Groups

A group of radio buttons allows users to select a single option from a group of options. To create a group of radio buttons within the Toolbar, use the same GroupName property value to arrange toolbar items into a group.

Much like radio buttons, you can define separate checked buttons (with checked and unchecked state support). To create a checked button, set the GroupName property to a unique value. This changes an item's state (checked/unchecked) on every user click.

Related API members are as follows:

  • Checked — Specifies an item's checked state.
  • CheckedChanged — Fires when an item's checked state changes.
  • Click — Fires when a user clicks the item.

 Templates

Our Blazor Toolbar component supports the use of templates. Use templates to customize the layout and appearance of a toolbar's title and associated toolbar items.

  • TitleTemplate — Specifies the template used for a toolbar's title.
  • Template — Specifies the template used for the toolbar item.

 Adaptivity

The Toolbar component supports adaptivity. The following properties control how the toolbar responds to changes made to a container width: