ToolBarItem

You can use the ToolBarItem component to add toolbar items to the title bar using the toolbar universal attribute.

NOTE

This component is supported since API version 20. Updates will be marked with a superscript to indicate their earliest API version.

This component is typically used with the toolbar universal attribute.

Child Components

This component can contain a single child component.

APIs

ToolBarItem

ToolBarItem(options?: ToolBarItemOptions)

Creates a toolbar item at the beginning of the corresponding column in the title bar by default. The column position is determined by the component's toolbar attribute configuration.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
options ToolBarItemOptions No Optional parameters for ToolBarItem, including the placement parameter of the ToolBarItemPlacement type.
Default value: placement: ToolBarItemPlacement.TOP_BAR_LEADING

Attributes

The universal attributes are not supported.

ToolBarItemOptions

Provides optional parameters for ToolBarItem configuration.

System capability: SystemCapability.ArkUI.ArkUI.Full

Name Type Read-Only Optional Description
placement ToolBarItemPlacement No Yes Placement position of the toolbar item.
Default value: ToolBarItemPlacement.TOP_BAR_LEADING.
ToolBarItemPlacement.TOP_BAR_LEADING: places the item at the start of the top bar.
ToolBarItemPlacement.TOP_BAR_TRAILING: places the item at the end of the top bar.

ToolBarItemPlacement

Enumerates the placement options for toolbar items in the title bar.

System capability: SystemCapability.ArkUI.ArkUI.Full

Name Value Description
TOP_BAR_LEADING 0 Places the item at the start of the top bar.
TOP_BAR_TRAILING 1 Places the item at the end of the top bar.

Example

See toolbar.