v7.3.0

Toolbar
Widget

A horizontal (or vertical) container for buttons and other widgets, typically docked to the top or bottom of a Panel. Items overflow gracefully into a menu when the toolbar is too narrow. Use the special string shortcuts '->' (spacer) and '|' (separator) to arrange items. Supports drag-drop reordering of items via enableReordering.

const toolbar = new Toolbar({
    items : {
        add    : { text : 'Add', icon : 'fa fa-plus' },
        remove : { text : 'Remove', icon : 'fa fa-minus' },
        spacer : '->',
        save   : { text : 'Save', icon : 'fa fa-check' }
    },
    appendTo : document.body
});

Useful configs and properties

Config Description
items Child widgets (buttons, fields, spacers, separators)
overflow Overflow handling configuration
enableReordering Allow drag-drop reordering of toolbar items

Arranging widgets

When passing an object (the approach we recommend for defining items), you can use -> as the property value to push widgets to the right side (in LTR):

items : {
    leftButton1  : { text : 'Left button 1', icon : 'fa fa-plus' },
    leftButton2  : { text : 'Left button 2', icon : 'fa fa-minus' },
    spacer       : '->',
    rightButton1 : { text : 'Right button 1', icon : 'fa fa-gear'}
}

When passing an array of items, you can similarly use the special -> item to push widgets to the right side:

items : [
    { text : 'Left button 1', icon : 'fa fa-plus' },
    { text : 'Left button 2', icon : 'fa fa-minus' },
    '->',
    { text : 'Right button 1', icon : 'fa fa-gear'}
]

Toolbar items can be drag-dropped

You can let users reorder the toolbar items by setting enableReordering to true.

This is not supported if you use weight to order the items.

See also

  • PagingToolbar - Toolbar with built-in paging controls
  • Panel - Panel with tbar/bbar docking support
  • Button - Default child widget type
No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • Set to true to allow users to reorder items in this toolbar using drag-drop

    Has a corresponding runtime enableReordering property.

  • labelPosition : 'before'/'above'/'align-before'/'auto'/nullbefore

    Toolbars override the default labelPosition for containers, placing labels before the input fields independent of which theme is used.

    Has a corresponding runtime labelPosition property.

  • Custom CSS class to add to toolbar widgets

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isToolbar : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of Toolbar class, or subclass thereof.
  • Set to true to allow users to reorder items in this toolbar using drag-drop

    Has a corresponding enableReordering config.

  • labelPosition : 'before'/'above'/'align-before'/'auto'/nullbefore

    Toolbars override the default labelPosition for containers, placing labels before the input fields independent of which theme is used.

    Has a corresponding labelPosition config.

  • isToolbar : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of Toolbar class, or subclass thereof.

Functions

Functions are methods available for calling on the class
  • onDrop( )
    private

    Handle drop

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

Event handlers

Event handlers are callbacks called as a result of certain actions in this class

Type definitions

CSS variables

CSS variables that can be set to adjust appearance
Name Description
--b-toolbar-background Toolbar background
--b-toolbar-gap Gap between toolbar items
--b-toolbar-justify-content Content justification
--b-toolbar-padding Toolbar padding
--b-toolbar-separator-color Toolbar separator color ("|" items)
--b-toolbar-separator-height Toolbar separator height ("|" items)
type: toolbar

Source path

Core/widget/Toolbar.js

Contents