Tabs widget
Overview
The Magento tabs widget implements single content area with multiple panels, each associated with a header in a list. It uses the Magento collapsible widget.
The tabs widget source is lib/web/mage/tabs.js.
Initialize the tabs widget
For information about how to initialize a widget in a JS component or .phtml
template, see the Initialize JavaScript topic.
Generally the tabs widget is instantiated like following:
$("#element").tabs();
Where:
#element
is the selector of the element for tabs is initialized.- Boolean: the
false
value disables the animation - Number: duration in milliseconds
- String: is parsed to an object as a json string
- Object:
{ duration: <Number>, easing: <String>, <propToAnimate>: <howToAnimate> }
For details about the object passed, see jQuery.animate().
-
Phtml template file examples using script:
Options
The tabs widget has the following options: * active * ajaxUrlElement * ajaxContent * animate * closedState * collapsible * collapsibleElement * content * disabled * disabledState * header * icons * loadingClass * openedState * openOnFocus * saveState * triggeractive
Index of the tab, which is active at the moment of initialization. Starts from "0"
**Type**: Number
**Default value**: `0`
ajaxUrlElement
Selector for the tab element, which contains the URL for the Ajax request.
The option of the collapsible widget used by tabs.
**Type**: String
**Default value**: `[data-ajax=true]`
ajaxContent
Defines if the content is loaded by Ajax request.
The option of the collapsible widget used by tabs.
**Type**: Boolean
**Default value**: `false`
animate
Specifies if the collapse/expand actions are performed with animation. The option of the collapsible widget used by tabs.
**Type**:
Multiple types are supported:
closedState
Class assigned to the tab being closed.
**Type**: String
**Default value**: `null`
collapsible
If this option is set to false, the content is not collapsed when the panel is active. The option of the collapsible widget used by tabs.
**Type**: Boolean
**Default value**: `false`
collapsibleElement
Selector of the element for which the collapsible widget is initialized.
**Type**: String
**Default value**: `[data-role=collapsible]`
content
Selector for the content element, searched for using `.find()` on the main collapsible element. The option of the collapsible widget used by tabs.
**Type**: String
**Default value**: `[data-role=content]`
disabled
Array of the elements' indexes which are disabled when the widget is initialized.
**Type**: Array of numbers.
**Default value**: `[]`
disabledState
Class assigned to the tab being currently disabled.
**Type**: String
**Default value**: `null`
header
Selector for the header element, searched for using `.find()` on the main collapsible element.
The option of the collapsible widget used by tabs.
**Type**: String
**Default value**: `[data-role=title]`
icons
The classes for icons to be used in headers. If no classes are specified, icons are not be created. A new span is created and appended to the header, the classes for this span are automatically changed whenever the content gets expanded/collapsed.
The option of the collapsible widget used by tabs.
**Type**: String
**Default value**: { header: null, activeHeader: null }