Jump to content

Template:Navbox/doc

From bestpressey
Revision as of 07:02, 20 September 2026 by imported>Hason-LEK-SIN (Oh so it doesnt fix the problem?)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

__EXPECTED_UNCONNECTED_PAGE__

The {{Navbox}} template provides the framework for creating standard Wikipedia navigational templates quickly and easily, with little more than one or more lists of wikilinks. It comes equipped with default styles that are appropriate for the vast majority of use cases, and while they can be customized, doing so is not recommended. Using this template, or one of its "Navbox suite" sister templates (links at right), is highly recommended for standardization of form and function as well as convenience.

Templates using the classes class=navbox ({{navbox}}) or class=nomobile ({{sidebar}}) are not displayed in article space on the mobile web site of English Wikipedia. Mobile page views accounted for 60% to 70% of all page views from 2020 through 2025. Briefly, these templates are not included in articles because 1) they are not well designed for mobile, and 2) they significantly increase page sizes—bad for mobile downloads—in a way that is not useful for the mobile use case. You can review/watch phab:T124168 for further discussion.

Usage

Please remove the parameters that are left blank.

<syntaxhighlight lang="wikitext" copy="1" style="box-sizing: border-box; margin-left: 2rem; width: fit-content;">

Template:Navbox documentation </syntaxhighlight>

Parameters

Commonly used

The navbox uses lowercase parameter names, as shown in the box above. The required <syntaxhighlight lang="wikitext" inline style="display: none;" />|name= and <syntaxhighlight lang="wikitext" inline style="display: none;" />|title= parameters will create a one-line box if no other parameters are defined. Note that the <syntaxhighlight lang="wikitext" inline style="display: none;" />|above=, <syntaxhighlight lang="wikitext" inline style="display: none;" />|below= and <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= (etc.) parameters are optional.

The basic and most common parameters are as follows (see the § Parameter descriptions section below for the full list):

  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|name= – the navbox template page name (Wikipedia location).
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|title= – contents of the title bar, such as [[Widget stuff]].
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|listclass= – custom CSS classes (space-delimited if more than one) for all <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= cells, usually assigned the value <syntaxhighlight lang="text" class="" style="" inline="1">hlist</syntaxhighlight> to enable the horizontal formatting of lists; alternatively, use <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodyclass= to define classes for the entire navbox's <div> container tags.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|state= – controls when a navbox is expanded or collapsed.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|titlestyle= – custom CSS declarations appended to the full-width title bar's <syntaxhighlight lang="text" class="" style="" inline="1">style="…"</syntaxhighlight> attribute, for example:
    <syntaxhighlight lang="wikitext" inline style="display: none;" />|titlestyle=background-color: var(--background-color-neutral, #eaecf0); color: var(--color-base, #202122);.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupstyle= – custom CSS declarations appended to the <syntaxhighlight lang="text" class="" style="" inline="1">style="…"</syntaxhighlight> attributes of the table cells for all of the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= parameters, for example:
    <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupstyle=background-color: var(--background-color-disabled, #dadde3); color: var(--color-progressive, #36c);.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|above= – content to appear under the title bar and above the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= / <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= rows (such as a list of wikilinks related to general aspects of the navbox subject).
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|image= – an optional right-side image, formatted as a typically File: namespace wikilink, such as [[File:XX.jpg|80px<syntaxhighlight lang="wikitext" inline style="display: none;" />|alt=Alternate text<syntaxhighlight lang="wikitext" inline style="display: none;" />|link=]].
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|imageleft= – an optional left-side image, formatted in the same manner as the <syntaxhighlight lang="wikitext" inline style="display: none;" />|image= parameter described above.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= – the content shown in the table cell at the immediate left of <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= (if any <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= parameter is left undefined, the corresponding <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameter will receive a full-width, center-aligned table cell (by way of <syntaxhighlight lang="text" class="nowrap" style="" inline="1">style="text-align: center;"</syntaxhighlight>).
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= – a wikilist formatted series of page links.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|below= – optional content to appear at the bottom of the navbox directly beneath the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= / <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= rows.

Descriptions

The following is a complete list of parameters for using {{Navbox}}. In most cases, the only required parameters are <syntaxhighlight lang="wikitext" inline style="display: none;" />|name=, <syntaxhighlight lang="wikitext" inline style="display: none;" />|title= and <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1=, though "child" navboxes do not even require those. For consistency and ease of use, this template shares numerous common parameters with its sister templates in the Navbox suite, {{Navbox with columns}} and {{Navbox with collapsible groups}}. Parameters marked with a preceding superscript orange star (★…) are common to all Navbox suite templates.

Setup
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|name=
The name of the template, which is needed for the links to work properly on all pages where the template is transcluded; the shortcut value {{subst:PAGENAME}} can be assigned as it will be automatically replaced with the correct value when saved. This parameter is only required if the <syntaxhighlight lang="wikitext" inline style="display: none;" />|title= parameter is defined but neither the <syntaxhighlight lang="wikitext" inline style="display: none;" />|border= or <syntaxhighlight lang="wikitext" inline style="display: none;" />|navbar= parameters (which disable the navbar) are as well.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|state=autocollapsecollapsedexpandedplainoff
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=autocollapse (default) – The navbox is collapsed if there are two or more additional collapsible elements on the transcluding page, otherwise it will be expanded. For the technically-minded, perform a full-text search for autocollapse on MediaWiki:Common.js to review the underlying JavaScript.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=collapsed – The navbox always loads in the collapsed state.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=expanded – The navbox always loads in the expanded state.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=plain – The navbox always loads in the expanded state and the {{Code[hide]}} link on the right is suppressed, while the title remains centered (CSS <syntaxhighlight lang="css" class="" style="" inline="1">padding:</syntaxhighlight> is used to offset the V • T • E links).
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=off – As above, the navbox always loads in the expanded state with no <syntaxhighlight lang="text" class="" style="" inline="1">[hide]</syntaxhighlight> link on the right, however no CSS padding is used to keep the title centered. This is for advanced use only; the <syntaxhighlight lang="text" class="" style="" inline="1">plain</syntaxhighlight> option should suffice for most instances where the <syntaxhighlight lang="text" class="" style="" inline="1">[show]</syntaxhighlight>/<syntaxhighlight lang="text" class="" style="" inline="1">[hide]</syntaxhighlight> button needs to be hidden.
To have the navbox load in the expanded state when not transcluded and in the collapsed state when it is, use <noinclude> tags to wrap the value for the non-transcluded behavior (e.g., <noinclude>expanded</noinclude>).
Frequently, editors will wish to override a navbox's default initial state in transcluding pages on a case-by-case basis. This is easily accomplished by duplicating the {{{state}}} parameter in the new navbox and adding a fallback value to it of the desired default behavior keyword wrapped in <includeonly> tags. This allows any explicitly-defined values for the parameter to be passed through as-is to Template:Navbox without affecting the non-transcluded default state.
  • For example, <syntaxhighlight lang="wikitext" inline style="display: none;" />|state= will show the navbox expanded when viewing it on its own template page and yet remain auto-collapsed anywhere else it is transcluded without an explicit value defined for {{{state}}}.
  • A more determinative approach is with <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=, where the parameter value passed to {{Navbox}} on the template's own page would be <syntaxhighlight lang="text" class="" style="" inline="1">desired_non-transcluded_default</syntaxhighlight> while remaining <syntaxhighlight lang="text" class="" style="" inline="1">desired_transcluded_default</syntaxhighlight> wherever the navbox is transcluded.
    • Example 1: {{Aesthetics}} with <syntaxhighlight lang="text" class="" style="" inline="1">autocollapse</syntaxhighlight> as the default initial state. Most articles transclude it alongside other navboxes so it collapses automatically, but it's expanded on its own template page because it is the only navbox present.
    • Example 2: {{Historical currencies of Hungary}} whose default initial state is <syntaxhighlight lang="text" class="" style="" inline="1">expanded</syntaxhighlight> as implemented in the template source code with <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=. All transcluding articles show the content by default, unless there is a hypothetical article that specifies {{Historical currencies of Hungary|state=collapsed}} when transcluding.
    • Example 3: {{Alveolata}} with <syntaxhighlight lang="text" class="" style="" inline="1">collapsed</syntaxhighlight> as the default initial state, from the parameter configuration <syntaxhighlight lang="wikitext" inline style="display: none;" />|state=. All transcluding articles will show the template as collapsed by default, but the template will still be uncollapsed when displayed on its own page.
The template {{Collapsible option}} explains how to use the {{{state}}} parameter. It can be added to a <noinclude>...</noinclude> section after the template definition, or to the instructions on the {{Documentation subpage}}.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|navbar=plainoff
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|navbar=plain – Removes the links on the left side of the titlebar and automatically recalculates the CSS padding values to keep the title visually centered.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|navbar=off – Removes the links, but does not alter the CSS padding to compensate (this is for advanced use only; the <syntaxhighlight lang="text" class="" style="" inline="1">plain</syntaxhighlight> option should suffice for most instances where a navbar is not desired).
It is strongly recommended that the navbar should not be hidden so that users can easily edit the template as needed, and to keep a standard style across pages.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|border=childsubgroupnone
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|border=child or <syntaxhighlight lang="wikitext" inline style="display: none;" />|border=subgroup – Allows the navbox to be used as a borderless child that nests cleanly within another navbox, removing the outer border and the lateral padding so that it fits into one of the <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= areas of the parent navbox.
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|border=none – Removes the outer border and lateral padding from the navbox so it may be used as the child of another container (do not use the <syntaxhighlight lang="text" class="" style="" inline="1">none</syntaxhighlight> option inside of another navbox, only the <syntaxhighlight lang="text" class="" style="" inline="1">child</syntaxhighlight> / <syntaxhighlight lang="text" class="" style="" inline="1">subgroup</syntaxhighlight> keyword values are appropriate for nesting navboxes).
  • If unset (default), then a regular navbox is displayed with a one-pixel-wide border. An alternate way to specify the border to be a subgroup style is with the first unnamed/positional parameter alias, as {{Navbox|child|…}}
► See the § Child navboxes section for practical examples and a more complete description of using navboxes within one another.
Cells
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|title=
Text that appears centered in the top row of the table, usually a succinct description of the template's topic. This should not include any line breaks, but if a second line is needed, use {{-}} to ensure the title remains properly centered. Though this parameter is not technically mandatory, using {{Navbox}} is rather pointless without a title.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|above=
A full-width cell displayed between the titlebar and first <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= / <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= row, i.e. above the template's body (groups, lists and image). In navboxes without an image, this parameter behaves in the same way as the <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1= parameter without the <syntaxhighlight lang="wikitext" inline style="display: none;" />|group1= parameter.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|groupN=
(i.e. <syntaxhighlight lang="wikitext" inline style="display: none;" />|group1=, <syntaxhighlight lang="wikitext" inline style="display: none;" />|group2=, etc.) When defined, its value appears in a header cell displayed to the left of the corresponding <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameter. If undefined, <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= uses the full width of the navbox and is center-aligned.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|listN=
(i.e. <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1=, <syntaxhighlight lang="wikitext" inline style="display: none;" />|list2=, etc.) The fundamental content elements of the navbox, usually each consisting of a list of wikilinks. They are rendered using inline formatting—though the text can be entered on separate lines if the entire list is enclosed within <div> tags—and may be preceded by a header cell whose content is defined by the corresponding <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= parameter. The <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1= parameter is required, and any additional <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameters that may be defined are each displayed on a separate row. The keyword values <syntaxhighlight lang="text" class="" style="" inline="1">child</syntaxhighlight> or <syntaxhighlight lang="text" class="" style="" inline="1">subgroup</syntaxhighlight> are also available to denote that the element is a nested or "child" navbox instance (does not work with {{Navbox with columns}} or {{Navbox with collapsible groups}}).
List entries should be separated using a newline followed by an asterisk (*). If instead, multiple asterisks precede an entry, it will be presented as a nested parenthetical to the previous entry, with each additional asterisk serving to increment the level of imbrication.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|image=
An image to be displayed in a cell below the title bar and to the right of the body rows (the groups/lists); requires the <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1= parameter to be defined. This parameter expects a value in the form of a standard file wikilink, e.g., [[File:Xxx.jpg|80px<syntaxhighlight lang="wikitext" inline style="display: none;" />|alt=<syntaxhighlight lang="wikitext" inline style="display: none;" />|class=<syntaxhighlight lang="wikitext" inline style="display: none;" />|link=]]. N.B.: Including the location token <syntaxhighlight lang="wikitext" inline style="display: none;" />|right in the file wikilink produces appropriate visual separation for the image from the list cells' zebra striping as well as individual list items.
► Note that the majority of such images do not comply with the policies outlined at Wikipedia:Manual of Style/Icons and may be subject to removal without warning; additional details can be found at Wikipedia:Navigation template. An example of a compliant use case would be this map showing the location of a region within the state of Kazakhstan that is consistently implemented for all of that country's regional navbox templates.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|imageleft=
An image to be displayed in a cell below the title bar and to the left of the body rows (the groups/lists); requires the <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1= parameter to be defined and that all <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= parameters are unset. Valid values for this parameter must satisfy the same requirements as for the <syntaxhighlight lang="wikitext" inline style="display: none;" />|image= parameter.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|below=
A full-width cell displayed below the body rows (the groups, lists and images). If neither the <syntaxhighlight lang="wikitext" inline style="display: none;" />|image= or <syntaxhighlight lang="wikitext" inline style="display: none;" />|imageleft= parameters are defined, this parameter behaves in the same way as the final <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameter when its corresponding <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= parameter is unset. An example of a common use case for this parameter can be found at this 2025 version of Template:Hosiery. Links placed here that lead to pages outside of the main namespace are customarily identified by prepending {{Icon|namespace}} and a non-breaking space to them, following the format:
<syntaxhighlight class="nowrap" lang="wikitext" inline="1"> Example</syntaxhighlight>.
Style

Custom styles are generally advised against in the interest of consistency among pages and templates on Wikipedia, but the option to modify the default CSS styles is provided through parameters detailed below.

★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|bodystyle=
Additional CSS declarations to append to the template body defaults; this option should be used sparingly as it can lead to visual inconsistencies. Some examples:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle=background-color: var(--background-color-disabled, #dadde3); color: var(--color-emphasized, #101418);
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle=clear: bothleftrightnone; float: leftrightnone;
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle=width: [Nem, N%, Npx, auto];
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|basestyle=
A convenience parameter that greatly simplifies changing the general color scheme of a navbox by appending a set of additional CSS declarations to the defaults for the <syntaxhighlight lang="wikitext" inline style="display: none;" />|title=, <syntaxhighlight lang="wikitext" inline style="display: none;" />|above=, <syntaxhighlight lang="wikitext" inline style="display: none;" />|below= and all of the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= cells; note that this parameter has no impact on any of the <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= cells, though. Example:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|basestyle=background-color: var(--background-color-content-added, #a3d3ff); color: var(--color-inverted, #fff);
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|titlestyle=
Additional CSS declarations to append to the defaults for the <syntaxhighlight lang="wikitext" inline style="display: none;" />|title= table cell, most often to customize its background and font colors. Examples:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|titlestyle=background-color: var(--background-color-option-orange, #ffead4); color: var(--color-base, #202122);
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|titlestyle=background: none; color: inherit; – for no background color
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|groupstyle=
Additional CSS declarations to append to the defaults for each of the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= cells, overriding any declarations that have been applied to the entire navbox. Examples:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupstyle=background-color: var(--background-color-option-maroon, #f6ebeb); color: var(--color-neutral, #404244);
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupstyle=text-align: leftcenterrightjustify; vertical-align: topmiddlebottom;
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|groupNstyle=
Additional CSS declarations to append to the defaults for a specific <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= parameter table cell, in addition to any declarations inherited from the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupstyle= parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity. Example:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|group1style=background-color: var(--background-color-option-lime, #e3f2e4); color: var(--color-destructive, #bf3c2c);
<syntaxhighlight lang="wikitext" inline style="display
none;" />|groupwidth=
A valid CSS length value (typically consisting of numeric and unit suffix components) specifying a uniform width for the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= cells, in cases where a lack of content in the list cells may cause group cells to be expand undesirably; may be overridden by the <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupNstyle= parameter. Example:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupwidth=8rem
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|liststyle=
Additional CSS declarations to append to the defaults for all <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameter table cells; individual declarations can be overridden by declarations of the same CSS properties in the <syntaxhighlight lang="wikitext" inline style="display: none;" />|oddstyle= and <syntaxhighlight lang="wikitext" inline style="display: none;" />|evenstyle= parameters, if specified.
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|listNstyle=
Additional CSS declarations to append to the defaults for a specific <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameter table cell, in addition to any declarations inherited from the <syntaxhighlight lang="wikitext" inline style="display: none;" />|liststyle= parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity. Example:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1style=background-color: var(--background-color-success-subtle, #dff2eb); color: var(--color-subtle, #54595d);
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|listpadding=
One or more valid CSS length values (typically consisting of numeric and unit suffix components) specifying the amount of padding in each <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameter table cell. This value must be valid for the CSS <syntaxhighlight lang="text" class="" style="" inline="1">padding:</syntaxhighlight> shorthand property as-is, and override the default of 0.25em on the left/right and 0 on the top/bottom. Due to the technical intricacies of this template's structure, it is not possible to set the <syntaxhighlight lang="text" class="" style="" inline="1">padding:</syntaxhighlight> property as part of the <syntaxhighlight lang="wikitext" inline style="display: none;" />|liststyle= parameter but only with this one. Examples:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|listpadding=0 0.5em – sets the top/bottom padding width to 0 and the left/right width to 0.5em
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|listpadding=0 – removes all padding for every list cell
<syntaxhighlight lang="wikitext" inline style="display
none;" />|evenstyle=,
<syntaxhighlight lang="wikitext" inline style="display
none;" />|oddstyle=
Additional CSS declarations to append to the defaults for only the even- or odd-numbered <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameter table cells, respectively, overriding any CSS declarations inherited from the <syntaxhighlight lang="wikitext" inline style="display: none;" />|liststyle= parameter. The default behavior is to produce a zebra stripe appearance by slightly darkening the background of the even-numbered <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= cells, in order to improve readability; this should not be changed except in extraordinary circumstances.
<syntaxhighlight lang="wikitext" inline style="display
none;" />|evenodd=swapevenoddoff
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|abovestyle=,
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|belowstyle=
Additional CSS declarations to append to the defaults for the table cells defined by the <syntaxhighlight lang="wikitext" inline style="display: none;" />|above= or <syntaxhighlight lang="wikitext" inline style="display: none;" />|below= parameters, respectively; typically used to customize theme colors or text alignment. Examples:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|abovestyle=background-color: var(--background-color-error, #f54739); color: var(--color-inverted, #fff);
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|belowstyle=text-align: leftcenterrightjustify;
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|imagestyle=,
★ <syntaxhighlight lang="wikitext" inline style="display
none;" />|imageleftstyle=
Additional CSS declarations to append to the table cell defaults for the <syntaxhighlight lang="wikitext" inline style="display: none;" />|image= and <syntaxhighlight lang="wikitext" inline style="display: none;" />|imageleft= parameters. These styles should only be used in exceptional circumstances, such as fixing width problems that can arise when all the <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameters have too few entries. Example:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|imagestyle=width: [Nem, N%, Npx, auto];
Default styles

The style parameters shown below are those that editors using {{Navbox}} customize most often; the other more complex style settings were left out of this list to keep it concise. If you need to discover defaults for any omitted parameters, consult the single source of truth for these styles at Module:Navbox and Module:Navbox/styles.css.

Default CSS declarations for style parameters
Parameter Declarations
<syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle= <syntaxhighlight lang="text" class="" style="" inline="1">background-color: #fdfdfd; color: inherit; vertical-align: middle; width: 100%;</syntaxhighlight>
<syntaxhighlight lang="wikitext" inline style="display: none;" />|titlestyle= <syntaxhighlight lang="text" class="" style="" inline="1">background-color: #ccf; line-height: 1.5em; padding: 0.25em 1em; text-align: center;</syntaxhighlight>
<syntaxhighlight lang="wikitext" inline style="display: none;" />|abovestyle= <syntaxhighlight lang="text" class="" style="" inline="1">background-color: #ddf; line-height: 1.5em; padding: 0.25em 1em; text-align: center;</syntaxhighlight>
<syntaxhighlight lang="wikitext" inline style="display: none;" />|belowstyle= <syntaxhighlight lang="text" class="" style="" inline="1">background-color: #ddf; line-height: 1.5em; padding: 0.25em 1em; text-align: center;</syntaxhighlight>
<syntaxhighlight lang="wikitext" inline style="display: none;" />|groupstyle= <syntaxhighlight lang="text" class="" style="" inline="1">background-color: #ddf; line-height: 1.5em; padding: 0.25em 1em; text-align: right; white-space: nowrap;</syntaxhighlight>
<syntaxhighlight lang="wikitext" inline style="display: none;" />|liststyle= <syntaxhighlight lang="text" class="" style="" inline="1">border-color: #fdfdfd; border-left: var(--spacing-12, 2px) var(--border-style-base, solid); text-align: left/center;</syntaxhighlight>
<syntaxhighlight lang="wikitext" inline style="display: none;" />|evenstyle= <syntaxhighlight lang="text" class="" style="" inline="1">background-color: #f7f7f7; color: inherit; line-height: 1.5em;</syntaxhighlight>
<syntaxhighlight lang="wikitext" inline style="display: none;" />|oddstyle= <syntaxhighlight lang="text" class="" style="" inline="1">background-color: transparent; color: inherit; line-height: 1.5em;</syntaxhighlight>

Since <syntaxhighlight lang="wikitext" inline style="display: none;" />|oddstyle= has a transparent background, odd list table cells will have the color defined by the <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle= parameter: #fdfdfd by default (white with a hint of gray). Individual <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= cells whose corresponding <syntaxhighlight lang="wikitext" inline style="display: none;" />|groupN= is also defined default to <syntaxhighlight lang="text" class="" style="" inline="1">text-align: left;</syntaxhighlight>, and if it is not the default becomes <syntaxhighlight lang="text" class="" style="" inline="1">text-align: center;</syntaxhighlight>. Since only the <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle= parameter has a default declaration for the <syntaxhighlight lang="text" class="" style="" inline="1">vertical-align:</syntaxhighlight> property, all the others inherit it.

Class

<syntaxhighlight lang="wikitext" inline style="display
none;" />|bodyclass=
Additional CSS classes to append to the defaults for the navbox as a whole.
<syntaxhighlight lang="wikitext" inline style="display
none;" />|titleclass=
Additional CSS classes to append to the defaults for the title bar table cell.
<syntaxhighlight lang="wikitext" inline style="display
none;" />|aboveclass=
Additional CSS classes to append to the defaults for the above parameter table cell.
<syntaxhighlight lang="wikitext" inline style="display
none;" />|belowclass=
Additional CSS classes to append to the defaults for the below parameter table cell.
<syntaxhighlight lang="wikitext" inline style="display
none;" />|groupclass=,
<syntaxhighlight lang="wikitext" inline style="display
none;" />|listclass=
Additional CSS classes to append to the defaults for group or list table cells. The most common use for the listclass parameter is to add the <syntaxhighlight lang="text" class="" style="" inline="1">hlist</syntaxhighlight> class that will cause lists to render horizontally. All of these parameters will accept that class, but in the event that it needs to be added to more than one of the class parameters, it is preferable that it is added only to <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodyclass=hlist instead, from where it will propagate automatically to all of the others.
{{Navbox}} automatically adds the class <syntaxhighlight lang="text" class="" style="" inline="1">nowraplinks</syntaxhighlight> to the listN table cells, but that can be overridden manually as needed by setting <syntaxhighlight lang="wikitext" inline style="display: none;" />|listclass=wraplinks.
  • The use of the {{Nowrap begin}}, {{·}} and {{•}} templates as wrappers for navbox parameter values in order to produce horizontally-formatted lists is deprecated in favor of adding the <syntaxhighlight lang="css" class="" style="" inline="1">hlist</syntaxhighlight> class to this template's listclass parameter; see Template:Flatlist § Technical details for a technical explanation of how the class works.

Advanced

<syntaxhighlight lang="wikitext" inline style="display
none;" />|innerstyle=
A very advanced parameter to be used only for advanced meta-templates employing the navbox. Internally, the navbox uses an outer table to draw the border, and then an inner table for everything else (title, above, groups, lists, below, images, etc.). The bodystyle parameter sets the CSS declarations for the outer table which are then inherited by the inner table, but in advanced cases (i.e. meta-templates) it may be necessary to directly set the style for the inner table. This parameter provides access to that inner table so that its CSS declarations can be manipulated; use at your own risk.
<syntaxhighlight lang="wikitext" inline style="display
none;" />|nowrapitems=
Defining any non-null value for this parameter applies the <syntaxhighlight lang="css" class="" style="" inline="1">nowrap</syntaxhighlight> class to each entry in all of the listN parameters and likewise to any lists within the above and below parameters.
<syntaxhighlight lang="wikitext" inline style="display
none;" />|orphan=
Defining any non-null value to this parameter within a nested or "child" navbox fixes odd/even zebra striping inconsistencies and removes it from Category:Navbox orphans.

Microformats

This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. To flag a navbox as containing hCard information about a person, for example, add these classes to the following parameters:

  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodyclass=vcard
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|titleclass=fn
Alternatively, they can be applied to individual elements like this:
  • <syntaxhighlight lang="wikitext" inline style="display: none;" />|title=The books of Iain Banks

Visit WikiProject Microformats for more information on adding microformat information to Wikipedia, and the microformat article for more information on microformats in general.

Table layout

Without image, above and below

This table is generated by {{Navbox}} without the image, above and below parameters defined (the gray list background color is added for illustration only):

With image, above and below

This table is generated by {{Navbox}} with the image, above and below parameters defined (the gray list background color is added for illustration only):

With image, but without groups

This table is generated by {{Navbox}} with image, imageleft, listN defined but without defining the groupN, above and below parameters (the gray list background color is added for illustration only):

Examples

No image

<syntaxhighlight lang="wikitext" style="box-sizing: border-box; margin-left: 2rem; width: 67vw;">

</syntaxhighlight>

With image

<syntaxhighlight lang="wikitext" style="box-sizing: border-box; margin-left: 2rem; width: 67vw;">

</syntaxhighlight>

Child navboxes

It is possible to place multiple navboxes within a single border. These can either be specified inline or by using a nested or "child" navbox template, although the latter method can result in a significantly large post-expand include size.

To specify nested or "child" navboxes inline, set the listN parameter value as <syntaxhighlight lang="text" class="" style="" inline="1">child</syntaxhighlight> or <syntaxhighlight lang="text" class="" style="" inline="1">subgroup</syntaxhighlight>. Elements of the child navbox can be specified by prepending childN_, subgroupN_ or just N_ to the parameter names (e.g., <syntaxhighlight lang="text" class="" style="" inline="1">1_list1</syntaxhighlight>). Another level of nested navboxes can be added with an additional prefix (e.g., <syntaxhighlight lang="text" class="" style="" inline="1">1_1_list1</syntaxhighlight>). The basic code for doing this is as follows (which adds a subgroup for the first group/list): <syntaxhighlight lang="wikitext" style="box-sizing: border-box; margin-left: 2rem; width: 67vw;">Lua error in Module:Navbar at line 58: Invalid title {{subst:PAGENAME}}.</syntaxhighlight>

To specify child navboxes using a nested template supply <syntaxhighlight lang="text" class="" style="" inline="1">child</syntaxhighlight> as the value to its first unnamed/positional parameter, or set the <syntaxhighlight lang="wikitext" inline style="display: none;" />|border= parameter. The basic code for doing this is as follows (which adds a subgroup for the first group/list): <syntaxhighlight lang="wikitext" style="box-sizing: border-box; margin-left: 2rem; width: 67vw;">Lua error in Module:Navbar at line 58: Invalid title {{subst:PAGENAME}}.</syntaxhighlight>

Subgroups example

This example shows two subgroups and an even deeper nested sub-subgroup created using <syntaxhighlight lang="text" class="" style="" inline="1">child</syntaxhighlight> or <syntaxhighlight lang="text" class="" style="" inline="1">subgroup</syntaxhighlight> keywords (they are equivalent and interchangeable); the striping is alternated automatically. To remove the striping altogether, set the <syntaxhighlight lang="wikitext" inline style="display: none;" />|childN_liststyle=background-color: transparent; parameter in each one.

Relationship with other Navbox templates

This navbox template works in conjunction with two other templates: {{Navbox with columns}} and {{Navbox with collapsible groups}}. All three of these templates share common parameters for consistency and ease of use (they are marked with a preceding superscript orange star (★…) in the parameter descriptions above). Most importantly, they can all be used as child templates of one another. Using the inline notation, the N_type parameter can be set to the values <syntaxhighlight lang="text" class="" style="" inline="1">with columns</syntaxhighlight> or <syntaxhighlight lang="text" class="" style="" inline="1">with collapsible groups</syntaxhighlight> to activate the compatibility for that type of child navbox, as shown in the example below.

You can also nest these or other navbox templates by assigning the keyword <syntaxhighlight lang="text" class="" style="" inline="1">child</syntaxhighlight> as the value of the first unnamed/positional parameter or the named <syntaxhighlight lang="wikitext" inline style="display: none;" />|border= parameter (e.g., {{Navbox|child|…}}, {{Navbox with columns|1=child|…}} or {{Navbox with collapsible groups|border=child|…}}). Note that this style of nesting can lead to a large increase in the template's post-expand include size.

Multiple visibility toggles

The example below is generated using a regular navbox for the main container with its <syntaxhighlight lang="wikitext" inline style="display: none;" />|listN= parameters all assigned the value <syntaxhighlight lang="text" class="" style="" inline="1">child</syntaxhighlight> (e.g., <syntaxhighlight lang="wikitext" inline style="display: none;" />|list1=child, <syntaxhighlight lang="wikitext" inline style="display: none;" />|list2=child, …). The v · t · e links are hidden automatically because the "child" or "subgroup" keyword is used, so defining <syntaxhighlight lang="wikitext" inline style="display: none;" />|navbar=plain for each of them is not necessary. The code N_state = {{#ifeq:{{{selected|}}}|ABBREVIATION|uncollapsed|{{{stateN|collapsed}}}}} is used to replicate the <syntaxhighlight lang="wikitext" inline style="display: none;" />|abbrN=ABBREVIATION functionality of {{Navbox with collapsible groups}}.

Technical details

  • The links are produced by Template:Navbar; if you have questions about them, it is probably best to ask at its talk page.
  • The two-pixel-wide border between groups and lists is drawn using the <syntaxhighlight lang="css" class="" style="" inline="1">border-left:</syntaxhighlight> property of the list cells. Thus, if you wish to change the background color of the template (for example <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle=background-color: purple;), then you'll need to make the <syntaxhighlight lang="css" class="" style="" inline="1">border-left-color:</syntaxhighlight> property for all list parameters have the same value (i.e. <syntaxhighlight lang="wikitext" inline style="display: none;" />|liststyle=border-left-color: purple;). If you wish to have a border around each list cell, then the 2px border between the list cells and group cells will disappear; you'll have to come up with your own solution.
  • Adjacent navboxes have only a one-pixel-wide border between them; if you set the top or bottom margin with the <syntaxhighlight lang="wikitext" inline style="display: none;" />|style= or <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle= parameters, then this will not work.
  • The default <syntaxhighlight lang="css" class="" style="" inline="1">margin-left:</syntaxhighlight> and <syntaxhighlight lang="css" class="" style="" inline="1">margin-right:</syntaxhighlight> properties of the outer navbox table are set to <syntaxhighlight lang="css" class="" style="" inline="1">auto</syntaxhighlight>. If you wish to use navbox as a float, you will need to manually set the margin-* property values because the auto value is incompatible with the float property. For example, add the following code to use the navbox as a float: <syntaxhighlight lang="wikitext" inline style="display: none;" />|bodystyle=float: right; margin-left: 1em; margin-right: 0; width: 22em;
  • Navbox templates, including this one, are a major contributor to the post-expand include size of pages, and can cause pages to exceed the limit and not render correctly. There are a multiple known methods for mitigating this.
    • {{Navbox}} can be replaced with {{#invoke:Navbox|navbox}}, which approximately halves the include size.
    • Nesting other templates inside of a navbox can cause the include size to increase by a factor of two or more. Using the inline child syntax documented at § Child navboxes mitigates this, but only for plain navboxes, navboxes with columns and navboxes with collapsible groups (but not any other navbox types).

Copying to other wikis

If you are trying to copy Template:Navbox to your local wiki, be aware that there are several prerequisites that must be installed or copied over as well:

  • The Scribunto and TemplateStyles extensions must be installed and activated.
  • Module:Navbox and its module and TemplateStyles dependencies, listed at Module:Navbox/doc
  • Optionally, the JavaScript code that enables support for the <syntaxhighlight lang="css" class="" style="" inline="1">mw-collapsible</syntaxhighlight> class states (autocollapse, innercollapse and outercollapse) may be copied from MediaWiki:Common.js, if dynamic collapsing is desired.

Tracking categories

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Navbox in articles based on its TemplateData.

TemplateData for Navbox

Creates a navigational box for links to other pages; does not display on mobile browsers.
Namename
The name of the template. Needed for "View • Talk • Edit" links to work properly.
Default
{{subst:PAGENAME}}
Default expansion statestate
Controls when a navbox is expanded or collapsed
Suggested values
  • autocollapse
  • collapsed
  • expanded
  • plain
  • off
Default
autocollapse
Titletitle
Text in the title bar; centered in the top row of the table. Usually the template's topic.
Example
[[Widget stuff]]
Title CSS classestitleclass
Additional CSS classes to declare for the title table row
Suggested values
  • fn
Title CSS styletitlestyle
Additional CSS declarations to define for the full-width title table cell
Body CSS classesbodyclass
Additional CSS classes to declare for the navbox's containing block element
Suggested values
  • vcard
Body CSS stylesbodystyle
Additional CSS declarations to append inline to the style attribute of the navbox's containing block element
Default
background-color: #fdfdfd; vertical-align: middle; width: 100%;
Border statusborder
1
When assigned either the 'child' or 'subgroup' keyword values, alters navbox styling to support nesting within another navbox template
Suggested values
  • child
  • none
  • subgroup
List padding sizelistpadding
A valid CSS length value specifying the padding in each list cell
Default
0 0.25em
List classlistclass
CSS class for the list cells, usually hlist for horizontal lists. Alternatively, use bodyclass for the whole box.
Suggested values
  • hlist
  • wraplinks
Default
nowraplinks
List CSS stylesliststyle
Custom CSS style declarations to apply to all lists. The default value for the text-align: property is left for lists with a corresponding |groupN= parameter defined and center for lists that do not.
Default
background: transparent; text-align: …;
Prevent line breaks inside list itemsnowrapitems
Applies the nowrap class to each list item individually in the |above=, |below= and all |listN= parameters
Example
yes
Alternating list background stripingevenodd
This template uses a slightly lighter background color for even-numbered |listN= parameters for ease of reading. If this parameter is assigned the keyword value swap, then lighter background is applied to odd-numbered |listN= parameters instead. Assigning the keyword values even or odd forces all rows to be displayed uniformly according to that row style, while the keyword value off disables the row striping effect entirely.
Suggested values
  • swap
  • even
  • odd
  • off
Default
on
evenstyleevenstyle
oddstyleoddstyle
Non-list CSS stylesbasestyle
Additional CSS declarations to append inline to the style attributes of the 'title', 'above', 'below' and 'group' table cells
Aboveabove
Full-width cell displayed between the titlebar and first group/list, i.e. above the template's body (groups, lists and image)
Above CSS classesaboveclass
Additional CSS classes to declare for the 'above' table cell
abovestyleabovestyle
groupwidthgroupwidth
Group CSS classesgroupclass
Additional CSS classes to define for all group name table cells
groupstylegroupstyle
Group 1group1
If specified, text appears in a header cell displayed to the left of list 1. If omitted, list 1 uses the full width of the navbox.
group1stylegroup1style
List 1list1
Body of the template; usually a list of links. Format is inline. At least one list parameter is required; each additional list is displayed in a separate row of the table. Each listn may be preceded by a corresponding groupn parameter. Entries should be separated using a newline and an asterisk. If two asterisks are used, it provides nesting within the previous entry with brackets.
list1stylelist1style
Group 2group2
If specified, text appears in a header cell displayed to the left of list 2. If omitted, list 2 uses the full width of the navbox.
List 2list2
Body of the template; usually a list of links. Format is inline. At least one list parameter is required; each additional list is displayed in a separate row of the table. Each listn may be preceded by a corresponding groupn parameter. Entries should be separated using a newline and an asterisk. If two asterisks are used, it provides nesting within the previous entry with brackets.
List 3list3
Body of the template; usually a list of links. Format is inline. At least one list parameter is required; each additional list is displayed in a separate row of the table. Each listn may be preceded by a corresponding groupn parameter. Entries should be separated using a newline and an asterisk. If two asterisks are used, it provides nesting within the previous entry with brackets.
Group 3group3
If specified, text appears in a header cell displayed to the left of list 3. If omitted, list 3 uses the full width of the navbox.
Group 4group4
If specified, text appears in a header cell displayed to the left of list 4. If omitted, list 4 uses the full width of the navbox.
List 4list4
Body of the template; usually a list of links. Format is inline. At least one list parameter is required; each additional list is displayed in a separate row of the table. Each listn may be preceded by a corresponding groupn parameter. Entries should be separated using a newline and an asterisk. If two asterisks are used, it provides nesting within the previous entry with brackets.
Group 5group5
If specified, text appears in a header cell displayed to the left of list 5. If omitted, list 5 uses the full width of the navbox.
List 5list5
Body of the template; usually a list of links. Format is inline. At least one list parameter is required; each additional list is displayed in a separate row of the table. Each listn may be preceded by a corresponding groupn parameter. Entries should be separated using a newline and an asterisk. If two asterisks are used, it provides nesting within the previous entry with brackets.
Group 6group6
If specified, text appears in a header cell displayed to the left of list 6. If omitted, list 6 uses the full width of the navbox.
List 6list6
Body of the template; usually a list of links. Format is inline. Each listn may be preceded by a corresponding groupn parameter. Entries should be separated using a newline and an asterisk. If two asterisks are used, it provides nesting within the previous entry with brackets.
Right-side imageimage
Image to be displayed in a cell below the title and to the right of the body
Example
[[File:XX.jpg | 80px | link= | alt= ]]
Image CSS classesimageclass
Additional CSS classes to declare for the (right) image table cell
imagestyleimagestyle
Left-side imageimageleft
Image to be displayed in a cell below the title and to the left of the body. For the image to display properly, list1 parameter must be specified and no groups can be specified.
Example
[[File:XX.jpg | 80px | link= | alt= ]]
imageleftstyleimageleftstyle
Belowbelow
Full-width cell displayed below the template's body.
Below CSS classesbelowclass
Additional CSS classes to declare for the below table cell
belowstylebelowstyle
Navbar statusnavbar
Suggested values
  • off
  • plain
navboxclassnavboxclass
innerstyleinnerstyle
orphanorphan
Example
yes

See also

  • {{Nowrap begin}}, {{·}} and {{•}} are deprecated in favor of this template's built-in <syntaxhighlight lang="wikitext" inline style="display: none;" />|listclass=hlist parameter for producing horizontally-formatted lists; see Template:Flatlist § Technical details for a technical explanation of how the <syntaxhighlight lang="css" class="" style="" inline="1">hlist</syntaxhighlight> class works.
Navigation templates comparison
Template Collapsible Image Groups Style (body)
parameter/s
{{Navbox}} collapsible Left/right of body Yes Yes
{{Navbox with collapsible groups}} collapsible Left/right of body and/or in each list Yes Yes
{{Navbox with columns}} collapsible Left/right of columns No Yes
Collapsible attributes
Type CSS classes JavaScript Collapses when Custom
initial state
Nesting
Collapsible tables mw-collapsible jQuery.makeCollapsible 2 or more autocollapse on page Yes Yes