Template:Navbox

From K6ka's Wiki
Jump to navigation Jump to search
Template documentation (View · Edit · History · Purge)

Description[edit]

This template is used to create a navbox. This template generally should not be used directly on pages, and should instead be used on other template pages, which are then transcluded into pages (Thus creating two transclusion layers instead of just one).

Full syntax[edit]

{{Navbox
|bodyclass  = 
|name       = {{subst:PAGENAME}}
|title      = 
|titleclass = 
|image      = 
|above      = 
|state      = 

|group1     = 
|list1      = 

|group2     = 
|list2      = 
 ...
|group20    = 
|list20     = 

|below      = 
}}

Parameters[edit]

An asterisk (*) denotes a mandatory parameter.

Setup parameters[edit]

name*

This determines where the "View", "Talk", and "Edit" links at the top of the navbox should point to. By default, it should the name of the template page where the navbox is located. Simply adding {{subst:PAGENAME}} to this parameter will suffice in most cases.

state

The default collapsed/uncollapsed state for the navbox. There are four acceptable inputs:

  • autocollapse: Causes the table to collapse when there are two or more collapsible navboxes on the page, and remain uncollapsed otherwise. This is the default setting.
  • collapsed: Forces it to always start off collapsed.
  • expanded or uncollapsed: Forces it to always start off expanded.
In the above three states, viewers can toggle a collapsible navbox's state by clicking on the "show" or "hide" button.
  • plain: Forces the navbox to always be expanded and disables the "show" and "hide" buttons. It also uses padding to center the title.
  • off: Forces the navbox to always be expanded and disables the "show" and "hide" buttons. Unlike plain, it does not center the title. This generally should only be used in special cases; in most cases, plain will suffice if the "show/hide" buttons need to be disabled.

In many cases, you will want to provide more flexibility for the navbox and allow editors to decide whether or not the navbox should be collapsed, expanded, or set to autocollapse on a case-by-case basis. This can be done by adding to the parameter. When the template is transcluded, editors will be able to use the |state = parameter to decide whether or not the template should be collapsed, expanded, or set to autocollapse on that particular page.

  • To make it start out collapsed by default, use collapsed
  • To make it start out expanded by default, use expanded
  • To make it start out autocollapsed by default, use autocollapse

In the above examples, editors will be able to choose the navbox's state on a case-by-case basis, but the navbox will default to a pre-set setting if the |state = parameter is left blank. For example, if you set a navbox to collapsed, and an editor uses |state = expanded, that navbox will be shown as expanded; however, if they leave the |state = parameter blank, it will be collapsed.

navbar

If set to plain, this disables the "View", "Talk", and "Edit" links that are displayed to the left of the titlebar, and padding will be used to keep the title centered. Setting it to off does the same thing, except that padding will not be used to center the title. The default setting is to leave this parameter blank, and it should generally be left blank in most circumstances.

border

This permits navboxes inside navboxes to look a bit nicer. If set to child or subgroup, the borders and padding on the sides of the navbox will be removed, allowing the navbox to fit snugly inside another one. If set to none, the borders and padding will be removed, allowing the template to be nested inside another element. The none parameter should not be used to nest a navbox inside another navbox; child or subgroup exists for that. It is automatically used by {{Navbox subgroup}}.

Cell parameters[edit]

title*

The title of the navbox which will be shown to everyone. It doesn't have to be the same name as the template.

above

Displays a full-width cell between the title and the first group/list. The cell will display any text you add to this parameter.

below

Similar to above, except that this cell is displayed below the template's body.

groupn

(i.e. group1, group2) If specified, this will create a cell to the left of listn and displays any text you add to this parameter in it. If omitted, listn will use the full width of the template. Up to a maximum of 20 groups are supported (i.e. group20 is the furthest you can go).

listn

(i.e. list1, list2) Displays the body of the template. Add the links you want to appear in the navbox here. At least one list parameter is required; any additional list parameters will be displayed as a separate row. Each listn may be preceded by a corresponding groupn parameter, if provided.

image

Displays an image that is located below the title and to the right of the lists. The list1 parameter must be defined for the image to work correctly. Use standard wikicode for displaying the image:

[[File:Example.png|80px|link=|alt=]]

N.B. Including "|right" will produce the usual left margin to provide separation from the list items and zebra striping.

imageleft

Similar to image, except that it displays images to the left of the lists. In order for the image to display properly, no group parameters can be specified. Follows the same syntax as image otherwise.

Style parameters[edit]

All style parameters are optional.

titleclass

Allows you to apply CSS styling to the title. This is often used to change the title's background colour by means of background: #nnnnnn; (For example, background-color:#BFD7FF;).

Examples:

titlestyle = background: #nnnnnn;
titlestyle = background: name;
titlestyle = background: none; — for no background color
bodystyle

CSS styles to be applied to the template body. Use sparingly as it may result in inconsistencies.

Examples:

bodystyle = background: #nnnnnn;
bodystyle = width: N [em/%/px or width: auto];
bodystyle = float: [left/right/none];
bodystyle = clear: [right/left/both/none];
basestyle

CSS styles to be applied to the title, above, below, and group cells all at once. Will not affect list cells.

Examples:

basestyle = background: lightskyblue;
groupstyle

CSS styles to apply to group cells. Overrides any styles that are applied to the entire table.

Examples:

groupstyle = background: #nnnnnn;
groupstyle = text-align: [left/center/right];
groupstyle = vertical-align: [top/middle/bottom];
groupnstyle

CSS styles to apply to a specific group, in addition to any styles specified by the groupstyle parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity.

Examples:

group3style = background: red; color: white;
groupwidth

A number and unit specifying a uniform width for the group cells, in cases where little content in the list cells may cause group cells to be too wide. No default. However, may be overridden by the group(n)style parameter.

Examples:

groupwidth = 9em
liststyles

CSS styles that are applied to all lists.

listnstyle

CSS styles to apply to a specific list, in addition to any styles specified by the liststyle parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity.

Examples:

list5style = background: #ddddff;
listpadding

A number and unit specifying the padding in each list cell. The list cells come equipped with a default padding of 0.25em on the left and right, and 0 on the top and bottom. Due to complex technical reasons, simply setting "liststyle = padding: 0.5em;" (or any other padding setting) will not work.

Examples:

listpadding = 0.5em 0; (sets 0.5em padding for the top/bottom, and 0 padding for the left/right.)
listpadding = 0; (removes all list padding.)
oddstyle
evenstyle

Applies to odd/even list numbers. Overrules styles defined by liststyle. The default behavior is to add striped colors (white and gray) to odd/even rows, respectively, in order to improve readability. These should not be changed except in extraordinary circumstances.

evenodd [swap, even, odd, off]

If set to swap, then the automatic striping of even and odd rows is reversed. Normally, even rows get a light gray background for striping; when this parameter is used, the odd rows receive the gray striping instead of the even rows. Setting to even or odd sets all rows to have that striping color. Setting to off disables automatic row striping. This advanced parameter should only be used to fix problems when the navbox is being used as a child of another navbox and the stripes do not match up.

abovestyle
belowstyle

CSS styles to apply to the top cell (specified via the above parameter) and bottom cell (specified via the below parameter). Typically used to set background color or text alignment:

abovestyle = background: #nnnnnn;
abovestyle = text-align: [left/center/right];
belowstyle = background: #nnnnnn;
belowstyle = text-align: [left/center/right];
imagestyle
imageleftstyle

CSS styles to apply to the cells where the image/imageleft sits. These styles should only be used in exceptional circumstances, usually to fix width problems if the width of groups is set and the width of the image cell grows too large.

Examples:

imagestyle = width:5em;

Default styles[edit]

By default, navboxes have a very plain style. To use the default styles used on the English Wikipedia, copy and paste the following parameters into a navbox template:

|bodystyle  = background: #fdfdfd; width: 100%; vertical-align: middle;
|abovestyle = background: #ddddff; padding-left: 1em; padding-right: 1em; text-align: center;
|belowstyle = background: #ddddff; padding-left: 1em; padding-right: 1em; text-align: center;
|groupstyle = background: #ddddff; padding-left: 1em; padding-right: 1em; text-align: right;
|liststyle  = background: transparent; text-align: left/center;
|oddstyle   = background: transparent;
|evenstyle  = background: #f7f7f7;

Credits[edit]

This template's code was taken from Template:Navbox on The Sims Wiki. See also Template:Navbox on the English Wikipedia. Part of this template's documentation was taken from Template:Navbox/doc on Wikipedia.


Visit Template:Navbox/doc to edit this text! (How does this work?) (Refresh this text - why?)