Template:Collapsible option
A documentation helper for navigation boxes and other collapsible templates. Put it on a template's documentation page to explain the state parameter. It shows nothing in articles because it is only used on documentation pages.
Usage
On the documentation of, for example, Template:Rajasthan districts:
{{Collapsible option}}
{{Collapsible option|Rajasthan districts|default=collapsed}}
Parameters
| Parameter | Description |
|---|---|
1 |
Template name used in the examples. Default: the current page name (without /doc).
|
default |
The state used when no parameter is given. Default: autocollapse.
|
statename |
Name of the parameter, if the template uses a different one (default state).
|
heading |
Custom heading text. |
headlevel |
Heading level: 2, 3 or 4 (default).
|
nohead |
Any value = no heading. |
nobase |
Any value = leave out the introductory sentence. |
extra |
Extra text added at the end. |
Example output
How to manage this template's initial visibility
To set whether this template is shown open or closed when the page first loads, use the |state= parameter:
|state=collapsed– the template starts closed, showing only its title bar. Example:{{Example navbox |state=collapsed}}|state=expanded– the template starts open and fully visible. Example:{{Example navbox |state=expanded}}|state=autocollapse– the template starts closed only if another collapsible box is on the same page. Example:{{Example navbox |state=autocollapse}}
If the parameter is not given, the template's default state is collapsed. Readers can always open or close the box with the show/hide link in its title bar.
Making a template collapsible
For the state parameter to work, the template's main table needs the mw-collapsible class, for example:
{| class="wikitable mw-collapsible {{#switch:{{{state|}}}|collapsed=mw-collapsed|expanded=|autocollapse=autocollapse|#default=autocollapse}}"
! Title
|-
| Content
|}
collapsedandexpandedwork with standard MediaWiki (classmw-collapsible, plusmw-collapsedto start closed).autocollapseneeds a small script in MediaWiki:Common.js that closes such boxes when there are two or more on the page. Without it,autocollapseboxes stay open.
Documentation helper that explains the state= parameter (collapsed/expanded/autocollapse) of a collapsible template.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Template name | 1 | no description | Line | optional |
| Default state | default | no description
| Line | optional |
| Parameter name | statename | no description
| Line | optional |
| Heading | heading | no description | Line | optional |
| Heading level | headlevel | no description
| Number | optional |
| No heading | nohead | no description | Line | optional |
| No introduction | nobase | no description | Line | optional |
| Extra text | extra | no description | Content | optional |