Extension:Tabs/Usage

This is the documentation for the Tabs extension. If this extension has been enabled, you could also copy the contents from the README.txt file into a wiki page to also see live demonstrations of this extension.

Configuration
This extension has no configuration options in, but it does have the MediaWiki:tabs-dropdown-bgcolor message associated with it, which is not meant to be translated. This message contains the default value for the  style for dropdown menus. This needs to be a valid  value.

It also has the following internationalisation messages associated with it:


 * MediaWiki:tabs-tab-label - The default label for a tab. The  stands for the index of the tab.
 * MediaWiki:tabs-toggle-open - The default opening label for toggle boxes.
 * MediaWiki:tabs-toggle-close - The default closing label for toggle boxes.
 * MediaWiki:tabs-dropdown-label - The default label for a dropdown menu.

General usage information
Note: - This extension uses the  attribute for dropdown menus. This is in no way meant as encouragement for the use of this deprecated attribute anywhere other than this tag.

For both the  and   tags, parser functions can be used within the content of the tag, but not in the attributes. To use parser functions within the attributes, the  or   parser functions should be used. The  parser function will also work, but since the only attributes it can define are the   and   attributes, these don't allow complete support.

For example, this will not work:

 Foo Bar But this will work:

Toggle box
You can create a simple collapsible box by enclosing some content between. All content within the tags will be displayed within the toggle box.

Available attributes:

 * - If this attribute is set, the toggle box will appear collapsed when the page loads. Otherwise it will be opened.
 * - If this attribute is set, the toggle box can be placed within text without interrupting the flow of the text.
 * - See.
 * Name attributes:
 * - The label for the toggle box that indicates that clicking it will close the box. Default value is stored in the MediaWiki:tabs-toggle-open page.
 * - Same as, but for closing the toggle box. Default is stored in MediaWiki:tabs-toggle-close.
 * - If neither the  and   is defined, this value will be used for both states.
 * If only one of the  or   attributes is defined, the other will take its value. If neither is defined, and the   attribute is also not defined, the default values are taken from the respective MediaWiki pages.
 * - Use this attribute to define any styles for the toggle box container. Styles defined here will only affect the content of the toggle box, not the label.
 * Default HTML attributes:
 * - Determines the tooltip shown when hovering over the box.
 * - Use this attribute to define any styles for the box. This can also affect the box's label.
 * - Adds classes to the box.
 * - Adds an id to the box. This id must be unique on the page, as with any id.

Dropdown menus
Dropdown menus are made by simply defining the  attribute on a toggle box. They can be opened by either hovering over the label, or by clicking on the label to keep it opened even after moving away the cursor. Dropdown menus have an opening delay of 0.2 seconds built in to prevent accidental opening when hovering over the label, and to prevent accidental closing when accidentally moving the cursor off the dropdown. This delay is enough to prevent accidents like those, but is not enough to be bothersome.

Dropdown menus are heavily based on the code for toggle boxes, so will also resemble them in many ways. There are a couple of quite distinct differences though.

Since dropdown menus use the  tag for their content, it is permitted to use   tags directly within the dropdown menu's contents. Any other content is also allowed.

Dropdown menus will convert all list items and links placed within to specially styled list items. The only exception is that links show as they normally do when placed within unordered lists (any line starting with). This is also the only difference between ordered and unordered lists.

Any nested lists will be rendered as sub-menus in the dropdown menu. Nested lists are created by starting a line with multiple  or   characters. There is one limitation with this however: Individual nested lists can not alternate between ordered and unordered lists. Seperate levels can, however. For example, this is not allowed: But this is:
 * Menu item 1
 * Menu item 2
 * Sub-menu item 1
 * Sub-menu item 2
 * Menu item 1
 * 1) Menu item 2
 * 2) *Sub-menu item 1
 * 3) *Sub-menu item 2
 * 4) *#Sub-sub-menu item 1

Available attributes:

 * All attributes that are available for toggle boxes
 * - Must be defined for the toggle box to become a dropdown menu.
 * and  - These attributes are identical to the   attribute in dropdown menus. It is not possible to let the dropdown switch between 2 values. If the   attribute is set, that value will be used as label, otherwise the   value is used, and if neither of those values is set, the   value is used.
 * - Because of how the background-color styling for dropdown works (background styles are applied to all items within dropdowns, otherwise they would become transparent), background colors need to be defined seperately. This must be done in the  attribute. This attribute works exactly the same as the   style in CSS. This defaults to the value defined in MediaWiki:tabs-dropdown-bgcolor.

Tab menus
Tab menus can be used to make it possible to switch between different layouts. Anything within  tags is rendered as a tab menu. Individual tabs are then defined via a  tag.

Available attributes

 * - Use this attribute to define any styles for the tabs container. Styles defined here will only affect the container of the tabs, not the labels.
 * - If this attribute is set, the tab interface will be a much more plain layout, without a border around the container, and with the tab labels just being buttons above it, instead of the typical tab layout. This can be used to get more freedom in styling the interface.
 * - If this attribute is set, the tab's contents can be placed within text without interrupting the flow of the text. The difference between this and the default state of  is that with , the tab's contents are forced to a new line when placed at the end of a new line, when not the whole of the tab's contents fit on the same line.   tabs however will use up any space that's left at the end of the line, and fit in with the normal flow of the text just like normal text.
 * - Converts the tab's contents to a block element. This can be used to assure the tab's contents will be displayed as a block instead of an inline-block, in cases where the tab's contents should not be placed within a line of text. When both the  and   attributes are available, the   attribute will be ignored.
 * Name attributes:
 * - This will determine the index of the tab. This only works if the entered index is already the index of a defined tab. Otherwise, this attribute is ignored. If no valid index or matching name attributes are defined, the index is automatically set to be the next in the list of tabs.
 * - This attribute is used to define the text the label shows for the tab. If the entered name already exists within the tab, the contents of the  tag are automatically assigned to the existing tab. This also means no two tabs can have an identical label. This attribute will be ignored if the   attribute already refers to an existing tab. Whitespace is automatically removed from the start and end of this attribute's value.
 * Both
 * Default HTML attributes:
 * - Determines the tooltip shown when hovering over the box.
 * - Use this attribute to define any styles for the box. This can also affect the box's label.
 * - Adds classes to the box.
 * - Adds an id to the box. This id must be unique on the page, as with any id.
 * - Adds classes to the box.
 * - Adds an id to the box. This id must be unique on the page, as with any id.

Self-closing tabs
Self-closing tabs can be used to define a list of tabs at the top of the tab menu, for later use via the  attribute. Self-closing tabs only have an effect when a name is defined, and no (valid) index is defined. The syntax for self-closing tabs is

Parser function
As an alternative for the tab tag, the  parser function can also be used to simplify the syntax for tabs. The syntax for this parser function allows the following syntaxes:

These have the following effects:
 * 1) Each of the defined names will be set as  or   attributes, respectively.
 * 2) *All values that are numbers only will be automatically recognised as indices. For indices, surrounding whitespace is allowed, but internal whitespace or any non-number characters such as decimal points aren't.
 * 3) *If these condtions are not met, the entered value is interpreted as a name.
 * 4) *If the entered value contains only whitespace or is left empty, the index of that tab within the parser function is assumed.
 * 5) No indices or names are defined here, so the indices of the tabs within the parser functions are automatically assigned as index.
 * 6) The second tab will automatcally get, and the third tab will have no content:
 * 7) *If the third tab has a name defined in the list of names, then a [[#Self-closing tabs|self-closing tag.
 * 8) *If the third tab has an index defined, this tab is skipped, and no output is generated for this tab.
 * 9) This will define three tabs, "name 1", "name 2" and "name 3" using the self-closing syntax.
 * 10) When the content of a tab is  (where   is the place of the tab in the parser function), the contents of that tab are copied over to the tab that has   in it. This only works if the tab contains nothing other than , and the parser function's  th parameter is defined and not empty.

Nested combinations
In some cases, it is possible to put multiple of these boxes inside each other. For this to work however, the,   or   parser functions will have to be used whenever two of the same tags are used anywhere within each other. This is required because otherwise the wikicode parser will recognise the closing tag for the nested tag as the closing tag for the outer tag, and skip the rest of the content, which could cause problems.

For the  parser function, even boolean attributes (such as   or  ) need to have a value defined for them, otherwise they are not recognised as attributes. For example,  will not work (it will show a toggle box instead of a dropdown), while   will show a dropdown box.

All combinations of nesting multiple tags will work, except for nesting any tab menus inside other tab menus.