Toolbar
A container widget that can contain Buttons or other widgets, and is docked to the bottom or top of a Panel.
//<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'}
]
//<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.
weight to order the items.Configs
96
Configs
96Common
Content
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() { ... }
}
}
})
CSS
Custom CSS class to add to toolbar widgets
Misc
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.
Other
Set to true to allow users to reorder items in this toolbar using drag-drop
Toolbars override the default labelPosition for containers, placing labels before the input fields
independent of which theme is used.
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.nullDisable 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:
| Parameter | Type | Description |
|---|---|---|
overflow.type | scroll | menu |
|
overflow.repeat | ClickRepeaterConfig | A config object to reconfigure the
ClickRepeater which controls auto repeat speed when holding down the scroll buttons
when |
overflow.filter | function | A filter function which may return a falsy value to prevent toolbar items from being cloned into the overflow menu. |
DOM
Float & align
Layout
misc
Scrolling
Properties
85
Properties
85Class hierarchy
Other
Set to true to allow users to reorder items in this toolbar using drag-drop
Toolbars override the default labelPosition for containers, placing labels before the input fields
independent of which theme is used.
Content
CSS
DOM
Layout
Misc
Widget hierarchy
Functions
67
Functions
67Configuration
Events
Misc
Other
Widget hierarchy
Events
19
Events
19This 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Toolbar | The toolbar instance. |
item | Widget | The dragged item. |
domEvent | Event | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Toolbar | The toolbar instance. |
item | Widget | The dragged item. |
domEvent | Event | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Toolbar | The toolbar instance. |
item | Widget | The dragged item. |
valid | Boolean |
|
domEvent | Event | The browser event. |
Event handlers
19
Event handlers
19This 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Toolbar | The toolbar instance. |
item | Widget | The dragged item. |
domEvent | Event | The browser event. |
This event is called when a drag gesture has started.
new Toolbar({
onItemDragStart({ source, item, domEvent }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Toolbar | The toolbar instance. |
item | Widget | The dragged item. |
domEvent | Event | The browser event. |
This event is called when an item is dropped
new Toolbar({
onItemDrop({ source, item, valid, domEvent }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Toolbar | The toolbar instance. |
item | Widget | The dragged item. |
valid | Boolean |
|
domEvent | Event | The browser event. |
Typedefs
7
Typedefs
7Toolbar items:
'->'- push widgets to the right side'|'- add toolbar separatorWidgetConfig- object with widget configuration
CSS variables
37
CSS variables
37| Name | Description |
|---|---|
--b-toolbar-gap | Gap between toolbar items |
--b-toolbar-padding | Toolbar padding |
--b-toolbar-separator-height | Toolbar separator height ("|" items) |
--b-toolbar-justify-content | Content justification |
--b-toolbar-background | Toolbar background |
--b-toolbar-separator-color | Toolbar separator color ("|" items) |