Template:Expand/doc: Difference between revisions
Jump to navigation
Jump to search
Important:Do not use this template in the middle of a line. Start a new line, which also allows you to indent it using colons.
(Created doc.) |
(Being able to be indented appears to come with the price that {{expand}} can't be used in the middle of a line. It feels that this should be the way and not some margin_left parameter.) |
||
(10 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Doc/subpage}} | ||
<!-- Please place categories where indicated at the bottom of this page.) --> | <!-- Please place categories where indicated at the bottom of this page.) --> | ||
== Usage == | == Usage == | ||
Wraps content in a box that can dynamically be expanded or collapsed. | |||
{{important|Do not use this template in the middle of a line. Start a new line, which also allows you to indent it using colons. | |||
<source lang=html style=margin:0> | |||
Text {{Expand|margin_left=2em|Text}} Text <!-- breaks --> | |||
Text | |||
:{{Expand|Text}} <!-- good! --> | |||
Text | |||
</source> | |||
}} | |||
=== Parameters === | === Parameters === | ||
*{{param|1}} | * {{param|1}} – The content to expand or hide. | ||
*{{param|float}} | * {{param|float}} – Set to <code>left</code> or <code>right</code> if floating is desired. Using this parameter is preferable to adding <code>style=float:right</code> because this also adjusts the title alignment appropriately, see the example below. | ||
*{{param|title | * {{param|title}} – An optional title shown next to the expand button. | ||
*{{param|noborder | * {{param|titlestyle}} – Adds extra title style parameters. | ||
*{{param|color}} | * {{param|noborder}} – If non-zero, use no surrounding border. {{warning|It can become difficult to tell where the expanded text ends if the background colors are identical! Use this only if you would end up with double borders for example.}} | ||
*{{param|style | * {{param|startcollapsed}} – If set to 0, the content will initially be visible, otherwise collapsed. Default is 1. | ||
* {{param|color}} – The color of the left border and title, if used. | |||
* {{param|bgcolor|rgba(0,0,0,0.05)}} – The background color of the content. This defaults to <code>transparent</code> if {{param|noborder}} is not 0. | |||
* {{param|margin_bottom|1em}} – The border on the bottom. | |||
* {{param|margin_left|0}} – The border on the left. | |||
* {{param|style}} – Adds style parameters for the table that this template is based on. | |||
=== Examples === | === Examples === | ||
<code><nowiki>{{expand|{{ | <code><nowiki>{{expand|{{KV Breakable}}}}</nowiki></code> renders as follows. | ||
{{expand|{{ | {{expand|{{KV Breakable}}}} | ||
<code><nowiki>{{expand|{{ | <code><nowiki>{{expand|{{KV Breakable}}|noborder=1}}</nowiki></code> renders as follows. | ||
{{expand|{{ | {{expand|{{KV Breakable}}|noborder=1}} | ||
Line 23: | Line 39: | ||
<code><nowiki>{{expand| | <code><nowiki>:{{expand|Can be indented.}}</nowiki></code> renders as follows. | ||
{{expand| | :{{expand|Can be indented.}} | ||
Line 46: | Line 62: | ||
<includeonly>{{sandbox other|| | <includeonly>{{sandbox other|| | ||
<!-- Categories below this line, please --> | <!-- Categories below this line, please --> | ||
[[Category:Layout Container]] | |||
}}</includeonly> | }}</includeonly> |
Latest revision as of 23:39, 17 January 2025

This is a documentation subpage for Template:Expand.
Don't forget to purge the contents of the base page upon creating or editing this subpage.
Don't forget to purge the contents of the base page upon creating or editing this subpage.
Usage
Wraps content in a box that can dynamically be expanded or collapsed.

Text {{Expand|margin_left=2em|Text}} Text <!-- breaks -->
Text
:{{Expand|Text}} <!-- good! -->
Text
Parameters
- {{{1}}} – The content to expand or hide.
- {{{float}}} – Set to
left
orright
if floating is desired. Using this parameter is preferable to addingstyle=float:right
because this also adjusts the title alignment appropriately, see the example below. - {{{title}}} – An optional title shown next to the expand button.
- {{{titlestyle}}} – Adds extra title style parameters.
- {{{noborder}}} – If non-zero, use no surrounding border.
Warning:It can become difficult to tell where the expanded text ends if the background colors are identical! Use this only if you would end up with double borders for example.
- {{{startcollapsed}}} – If set to 0, the content will initially be visible, otherwise collapsed. Default is 1.
- {{{color}}} – The color of the left border and title, if used.
- {{{bgcolor|rgba(0,0,0,0.05)}}} – The background color of the content. This defaults to
transparent
if {{{noborder}}} is not 0. - {{{margin_bottom|1em}}} – The border on the bottom.
- {{{margin_left|0}}} – The border on the left.
- {{{style}}} – Adds style parameters for the table that this template is based on.
Examples
{{expand|{{KV Breakable}}}}
renders as follows.
Breakable (common):
|
{{expand|{{KV Breakable}}|noborder=1}}
renders as follows.
Breakable (common):
|
{{expand|color=yellow|title=Yellow|Yellow!}}
renders as follows.
Yellow! |
:{{expand|Can be indented.}}
renders as follows.
Can be indented.
{{expand |title=float{{=}}right |float=right | The title alignment also uses {{param|float}} so that the button stays at the same position when toggling. }}
The title alignment also uses {{{float}}} so that the button stays at the same position when toggling. |
See how this renders on the right.