This template is used onapproximately 323,000 pages. To avoid major disruption and server load, any changes should be tested in the template's/sandbox or/testcases subpages, or in your ownuser subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on thetalk page before implementing them.
This template doesnot display in the mobile view of Wikipedia; it isdesktop only. SeeTemplate:Navbox visibility for a brief explanation.
This template is ametatemplate for the creation of sidebar templates, i.e. boxes that arevertically alignednavigation templates. Sidebars, likeinfoboxes, are usually positioned on the right-hand side of a page.
{{Sidebar with collapsible lists}} is a version of{{Sidebar}} that adds collapsibility to its sections, i.e. the means to show or hide sections by clicking links beside their headings.
Templates using the classesclass=navbox ({{navbox}}) orclass=nomobile ({{sidebar}}) are not displayed in article space on themobile web site of English Wikipedia. Mobile page views account for approximately 68% of all page views (90-day average as of September 2024[update]). 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/watchphab:T124168 for further discussion.
Note thatWP:LEADSIDEBAR discourages the placement of sidebars in the lead section of articles, though they may be included on a case-by-case basis.
No parameters are mandatory. If{{navbar}} links are to function correctly (unless their appearance is suppressed; see thenavbar parameterbelow), the parametername needs to be set (tothe name of the sidebar's page). (This does not apply if theLua module that produces{{Sidebar}},Module:Sidebar, is being used directly.)
The sidebar's name, i.e. the name following "Template:" in the title shown at the top of the sidebar's page. Required if theV T E{{navbar}} links at the bottom of the sidebar are to function correctly, unless their appearance is suppressed (see thenavbar parameterbelow) or{{Sidebar}} is not being used as awrapper forModule:Sidebar. When{{Sidebar}} is used as a wrapper, setting|name={{subst:PAGENAME}} is recommended.
|float=
Accepts the valuesnone andleft. The former aligns the box left without floating and the latter with floating behavior. The default float is right and does not need specifying. Prefer this parameter (and passing it to any using templates such as with{{Helpbox}}) to specifying your own floats in TemplateStyles.
|outertitle=
Use to place a title for the sidebar immediately above the sidebar.
|topimage=
Use to place an image at the top of the sidebar, i.e. above|title= (if used). Full wiki syntax is expected (i.e.[[File:...]]). To add a caption below the image, use|topcaption=. PerWP:SIDEBAR this field should only be used to define a generic image for a sidebar, not to provide custom images for individual articles: sidebars are not displayed on mobile.
|pretitle=
Use to place a line such as "Part of theX series on" before the title.
|title=
Use to place a title for the sidebar at the top of the sidebar. (If|topimage= is used, it will appear immediately below it).
|image=
Use to place an image between the|title= (if used) and first section. As with|topimage=, full wiki syntax is expected (i.e.[[File:...]]). To add a caption below the image, use|caption=.
|headingn= |contentn=
Thenth heading / content.contentn is required ifheadingn is also to appear.
Classes can be used to make styles easier to target forTemplateStyles.|class= must be used for this purpose for an entire sidebar (otherwise a page with multiple sidebars may take styles intended only for one sidebar). An example for a template named "Template:Example Sidebar" might have the class|class=example-sidebar.
|headingnclass= and|contentnclass= can be used to target a specific heading or content group. This should be needed only rarely.
Dot before a class-name can be omitted:|class=foo.
|below=
Same as the|below= offered by{{Navbox}}. (Use, for example, to add one or more portal links to the bottom of the template (shown, by default, in bold).)
|navbar=
When|name= is specified,{{navbar}} is shown at the bottom of the sidebar. Setting|navbar=off or|navbar=none will suppress the
The TemplateStyles parameters|templatestyles=,|child templatestyles=, and|grandchild templatestyles= take the pagename of aTemplateStyles page and turn it into a TemplateStyles tag. The TemplateStyles tag is a much more powerful way to add styling to a sidebar.
Some rules of use:
Always add a template-specific class in|class= so that the styles added to one sidebar will not "leak" into another sidebar. For example,Template:DYK tools has|class=dyk-tools and theTemplate:DYK tools/styles.css page targets.dyk-tools for all of its added styling.
Do not assume Template:Sidebar will continue to have a table structure (i.e., do not targettable or any other table HTML in the TemplateStyles page). The table structure is soft-deprecated and will go away at some point in the future.
These tags are loaded in this order: Core templatestyles (Module:Sidebar/styles.css), templatestyles, child, and then grandchild, which can be used to 'cascade' the styles.
|templatestyles=
This parameter is intended for a template or module calling{{sidebar}} directly.
|child templatestyles=
This parameter is intended for a template or module which calls a sidebar with|templatestyles=.
|grandchild templatestyles=
This parameter is intended for a template or module which calls a sidebar with|child templatestyles=.
The canonical list of classes output with each kind of element of a sidebar (i.e. output for all|contentn=, or all cases of|above=) can be found inModule:Sidebar/configuration in the "class" table. The below is a non-authoritative but otherwise sufficient list for most generic styling:
.sidebar
The top-level sidebar class.
.sidebar-outer-title
The class associated with a|outertitle=.
.sidebar-top-image
The class associated with a|topimage=.
.sidebar-top-caption
The class associated with a|topcaption=.
.sidebar-pretitle
.sidebar-pretitle-with-top-image
The classes associated with a|pretitle=. Only one of these will be output per sidebar, depending on whether|topimage= is present.
.sidebar-title
.sidebar-title-with-pretitle
The classes associated with a|title=. Only one of these will be output per sidebar, depending on whether|pretitle= is present.
.sidebar-image
The class associated with a|image=.
.sidebar-caption
The class associated with a|caption=.
.sidebar-above
The class associated with a|above=.
.sidebar-heading
The class associated with a|headingn=. Every heading will have this class.
.sidebar-content
.sidebar-content-with-subgroup
The classes associated with|contentn=. Every content group will have one of these classes, depending on whether the specific content has a subgroup.
.sidebar-below
The class associated with a|below=.
.sidebar-navbar
The class associated with a|navbar=.
Example TemplateStyles parameter use
For an example of a sidebar which does not need to support children templates of its own (whether because it has no children or because it wants no children):
{{Normalwraplink}} may be used to handle individual links that should wrap within the sidebar or otherwise need to be made to wrap, in order to prevent the sidebar from becoming too wide. Use{{normalwraplink|longlinkname}}, where|longlinkname is the long link without its square brackets.
Use the|wraplinks=true parameter to enable link wrapping (disablingnowraplinks CSS class) for the whole template.
Nesting
One sidebar template can be nested (embedded) into another one by using the|child= parameter. This feature can be used to create a modular sidebar, or to create more well-defined and logical sections.
Note in the examples above that the child sidebar is placed in acontent field, not aheading field. Notice also that the section subheadings do not appear in bold if this is not explicitly specified. To obtain bold section headings, move the titles to theheading field, using
width attribute in the class assigned to the template in|class=
|basestyle=
Additional CSS for a grabbag of parameters:|pretitle=,|title=,|headingn=, and|listtitlen= (for{{sidebar with collapsible lists}}).
See related parameters for targeting pretitle, title, all headings, and all lists. Appliesbefore the specific style parameter so must be placed above that parameter's declarations if any in the TemplateStyles sheet.