Template:Spoiler/doc
This template is used to mark text and other elements as spoilers. Users can click or optionally hover to reveal their content.
The hoverShowSpoilers gadget
[edit]Users can enable the hoverShowSpoilers gadget to make spoilers show on hover, not just on click. The code for this gadget can be found at MediaWiki:Gadgets/hoverShowSpoilers/main.css.
Examples
[edit]| Code | Result |
|---|---|
{{spoiler|spoiler text}} (Click to toggle) |
span}}<{{#var:element}} class="spoiler-content" style=""><{{#var:element}}>spoiler text</{{#var:element}}></{{#var:element}}> |
{{spoiler|spoiler text with a [[Template:Navbox|link]]}} (Click to toggle) |
span}}<{{#var:element}} class="spoiler-content" style=""><{{#var:element}}>spoiler text with a link</{{#var:element}}></{{#var:element}}> |
{{spoiler|block=y|Really long spoiler that spans multiple lines
It even has a bulleted list inside it:
* Item a
* Item b
* [[Special:Random|Item c]]
}}
|
div}}<{{#var:element}} class="spoiler-content" style=""><{{#var:element}}>Really long spoiler that spans multiple lines
It even has a bulleted list inside it:
</{{#var:element}}></{{#var:element}}> |
Dependencies
[edit]For this template to work properly, you need the following:
- The
spoilersgadget with JavaScript code for toggling the.spoilerclass on/off on click: - The
.spoiler-contentand any related classes, found in MediaWiki:Common.css.
Source
[edit]Base code adapted from Template:Spoiler on Terraria Wiki.
TemplateData
[edit]<templatedata> { "params": { "1": { "aliases": [ "text" ], "label": "Text", "description": "The text to be shown.", "example": "Character A died during the battle.", "type": "content", "required": true }, "hover": { "label": "Show on Hover?", "description": "Show spoiler text on mouse hover.", "example": "hover=yes", "type": "boolean", "default": "hover=no" }, "block": { "label": "Display as block?", "description": "If given, display the spoiler as a block instead of inline. Useful for long spoilers spanning multiple lines or using block-level elements like lists.", "example": "y", "type": "boolean", "suggested": true }, "class": { "label": "Class", "description": "A class or classes to apply to the spoiler", "type": "string" }, "id": { "label": "ID", "description": "A unique CSS ID to apply to the spoiler. This is an optional parameter, and is not necessary for spoilers to function.", "type": "string" }, "style": { "description": "Inline CSS styles to pass in.", "type": "string", "aliases": [ "css" ], "label": "Style" } }, "description": "This template can be used to mark text as a spoiler.", "maps": { "1": {} }, "paramOrder": [ "1", "hover", "block", "class", "id", "style" ], "format": "inline" } </templatedata>