Toolbar

A container widget that can contain Buttons or other widgets, and is docked to the bottom or top of a Panel.

Toolbar
//<code-header>
fiddle.title = 'Toolbar';
//</code-header>
const toolbar = new Toolbar({
    appendTo : targetElement,
    items    : {
        addButton    : { text : 'Add', icon : 'fa fa-plus' },
        deleteButton : { text : 'Delete', icon : 'fa fa-trash' }
    }
});

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 positioning
//<code-header>
fiddle.title = 'Toolbar positioning';
//</code-header>
const toolbar = new Toolbar({
    appendTo : targetElement,
    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' }
    }
});

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.

Configs

96

Common

listenersEvents

Content

items: Object<String, (ToolbarItems|Boolean|null)> | ToolbarItems[] | Widget[]

An object containing typed child widget config objects or Widgets. Can also be specified as an array.

If configured as an Object, the property names are used as the child component's ref name, and the value is the child component's config object.

 new Toolbar({
     appendTo : document.body
     items    : {
         button : {
             type : 'button',
             onClick() { ... }
         }
     }
 })

Some special items can also be added:

  • -> Pushes following items to the other side
  • | Adds a vertical separator
 new Toolbar({
     appendTo : document.body
     items    : {
         button : {
             type : 'button',
             text : 'Click me',
             onClick() { ... }
         },
         separator : '|',
         name : {
             type : 'textfield',
             label : 'Enter name'
         },
         // Align following items to the end of the toolbar
         spacer : '->',
         saveButton : {
             type : 'button',
             text : 'Save',
             onClick() { ... }
         }
     }
 })
defaultsContainer
lazyItemsContainer
namedItemsContainer
textContentContainer
toolsToolable

CSS

widgetCls: String

Custom CSS class to add to toolbar widgets

borderContainer
clsWidget
colorWidget
htmlClsWidget
itemClsContainer
styleWidget
uiWidget

Misc

ignoreParentReadOnly: Boolean= true

Determines if the toolbars read-only state should be controlled by its parent.

When set to true, setting a parent container to read-only will not affect the widget. When set to false, it will affect the widget.

dataFieldWidget
disabledWidget
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
tooltipWidget

Other

Set to true to allow users to reorder items in this toolbar using drag-drop

labelPosition: before | above | align-before | auto | null= beforeAlso a property

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

overflow: String | Object | null= 'menu'

How this Toolbar should deal with items that overflow its main axis.

Values may be:

  • 'menu' A button with a menu is shown and the menu contains the overflowing items.
  • 'scroll' The items overflow and mey be scrolled into view using the mouse or scroll buttons.
  • null Disable overflow handling

When mode is 'menu', clones of overflowing toolbar item are created and added to a Menu. Any config changes to the original toolbar item are propagated to the menu's clone, so disabling a toolbar item will make the clone in the menu disabled.

The clone of an input field will propagate its value changes back to the original. The overflow button, its menu, and the clones should not be accessed or manipulated by application code.

Note that cloned items will be allocated a unique, generated ID because all IDs must be unique, so CSS targeting an element ID will not apply to a clone in the overflow menu.

Values may also be specified in object form containing the following properties:

ParameterTypeDescription
overflow.typescroll | menu

'scroll' or 'menu'

overflow.repeatClickRepeaterConfig

A config object to reconfigure the ClickRepeater which controls auto repeat speed when holding down the scroll buttons when type is 'scroll'

overflow.filterfunction

A filter function which may return a falsy value to prevent toolbar items from being cloned into the overflow menu.

columnWidget
defaultFocusContainer
renditionContainer
rtlRTL
spanWidget

Accessibility

ariaLabelWidget
keyMapKeyMap

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget
titleWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
hideWhenEmptyContainer
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

misc

tabBarItemsContainer

Record

recordContainer

Scrolling

Properties

85

Class hierarchy

isToolbar: Boolean= truereadonly
Identifies an object as an instance of Toolbar class, or subclass thereof.
isToolbar: Boolean= truereadonlystatic
Identifies an object as an instance of Toolbar class, or subclass thereof.
isContainerContainer
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isLocalizableLocalizable
isToolableToolable
isWidgetWidget

Other

Set to true to allow users to reorder items in this toolbar using drag-drop

labelPosition: before | above | align-before | auto | null= beforeAlso a config

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

$namestaticWidget
columnWidget
firstItemContainer
hasChangesContainer
isValidContainer
itemsContainer
lastItemContainer
renditionContainer
rtlRTL
spanWidget
typestaticWidget
valuesContainer

Accessibility

keyMapKeyMap

Content

toolsToolable

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
tooltipWidget

Record

recordContainer

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget
widgetMapContainer

Functions

67

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

addContainer
composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getAtContainer
getWidgetByIdContainer
insertContainer
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
removeContainer
removeAllContainer
resetValuesContainer
setValuesContainer
triggerEvents
unEvents
unmaskWidget

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

19

This event is fired on the owning Toolbar prior to starting a drag gesture. The drag is canceled if a listener returns false.

// Adding a listener using the "on" method
toolbar.on('beforeItemDragStart', ({ source, item, domEvent }) => {

});
ParameterTypeDescription
sourceToolbar

The toolbar instance.

itemWidget

The dragged item.

domEventEvent

The browser event.

This event is fired when a drag gesture has started.

// Adding a listener using the "on" method
toolbar.on('itemDragStart', ({ source, item, domEvent }) => {

});
ParameterTypeDescription
sourceToolbar

The toolbar instance.

itemWidget

The dragged item.

domEventEvent

The browser event.

This event is fired when an item is dropped

// Adding a listener using the "on" method
toolbar.on('itemDrop', ({ source, item, valid, domEvent }) => {

});
ParameterTypeDescription
sourceToolbar

The toolbar instance.

itemWidget

The dragged item.

validBoolean

true if the drop was valid.

domEventEvent

The browser event.

catchAllEvents
destroyEvents
focusInWidget
focusOutWidget
hideWidget
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget

Event handlers

19

This event is called on the owning Toolbar prior to starting a drag gesture. The drag is canceled if a listener returns false.

new Toolbar({
    onBeforeItemDragStart({ source, item, domEvent }) {

    }
});
ParameterTypeDescription
sourceToolbar

The toolbar instance.

itemWidget

The dragged item.

domEventEvent

The browser event.

This event is called when a drag gesture has started.

new Toolbar({
    onItemDragStart({ source, item, domEvent }) {

    }
});
ParameterTypeDescription
sourceToolbar

The toolbar instance.

itemWidget

The dragged item.

domEventEvent

The browser event.

This event is called when an item is dropped

new Toolbar({
    onItemDrop({ source, item, valid, domEvent }) {

    }
});
ParameterTypeDescription
sourceToolbar

The toolbar instance.

itemWidget

The dragged item.

validBoolean

true if the drop was valid.

domEventEvent

The browser event.

onDestroyEvents
onFocusInWidget
onHideWidget
onPaintWidget
onResizeWidget
onShowWidget

Typedefs

7

Toolbar items:

  • '->' - push widgets to the right side
  • '|' - add toolbar separator
  • WidgetConfig - object with widget configuration
AlignSpecWidget
ColorWidget

CSS variables

37
NameDescription
--b-toolbar-gapGap between toolbar items
--b-toolbar-paddingToolbar padding
--b-toolbar-separator-heightToolbar separator height ("|" items)
--b-toolbar-justify-contentContent justification
--b-toolbar-backgroundToolbar background
--b-toolbar-separator-colorToolbar separator color ("|" items)

Inherited