1. Template
  2. Table cell templates/doc

This page can be used as a building block in other pages.
<noinclude>{{Documentation subpage}}</noinclude>
{{For|the text color template|Template:Black}}
The templates in this series are designed to be used in a [[Help:Table|table]] to make a cell with text in that cell, with an appropriately colored background. They are commonly used in [[:Category:Comparisons|comparison tables]].

For example, {{Tlc|yes}} makes a cell with a green background. The text in the cell is taken from the [[Help:Template#Parameters|first parameter]]; <code><nowiki>{{</nowiki>yes|Sure}}</code> would output "Sure" otherwise it defaults to "Yes". Most templates allow authors to override the default text in this way, some require text put after the template call and some also need a vertical bar in between: <code><nowiki>{{</nowiki>''table cell template''}} ''text''</code> or <code><nowiki>{{</nowiki>''table cell template''}} | ''text''</code>. This information, the colors and default texts are found in the table below.

If you want to use other attributes for the table cells, ''e.g.'' <code>colspan</code> or <code>rowspan</code>, they need to be put before the template call and there must be no vertical bar <code>|</code> in between them:

{| class=wikitable align=right
!{{Yes}} ||{{No}} ||rowspan=2 {{n/a}}
|-
|colspan=2 {{Yes-No}}
|}
<pre>...
!{{Yes}} ||{{No}} ||rowspan=2 {{n/a}}
|-
|colspan=2 {{Yes-No}}
...
</pre>

== Templates ==
{| class="wikitable"
|+ Table cell templates
! Class !! Default syntax !! Preview (default) !! Customized syntax !! Preview (customized)
|-
|rowspan=2| <code>table-rh</code> || {{Tl|rh}} {{!}} Row header<ref name="table-cell-templates-table-after+pipe" /> || {{rh}} | Row header || {{tlp|rh|2=align=right}} {{!}} Row header || {{rh|align=right}} | Row header
|-
| {{Tl|rh2}} {{!}} Row header<ref name="table-cell-templates-table-after+pipe">Does not take a parameter; the content should be placed after the template call, separated by a pipe (|) character.</ref> || {{rh2}} {{!}} Row header || {{tlp|rh2|2=align=right}} | Row header || {{rh2|align=right}} | Row header
|-
|rowspan=2| <code>table-yes</code> || {{Tl|yes}} || {{yes}} || {{Tlp|yes|<nowiki>Customized [[Plain text|text]]</nowiki>}} ||{{yes|Customized [[Plain text|text]]}}
|-
| {{tl|Ya}} || {{Ya}} || {{tlp|Ya|Customized alt text|link{{=}}WP:ALT}} || {{Ya|Customized alt text|link=WP:ALT}}
|-
|rowspan=5| <code>table-no</code> || {{Tl|no}} || {{no}} || {{Tlp|no|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{no|Customized [[Plain text|text]]}}
|-
| {{tl|Na}} || {{Na}} || {{tlp|Na|Customized alt text|link{{=}}WP:ALT}} || {{Na|Customized alt text|link=WP:ALT}}
|-
| {{Tl|coming soon}} || {{coming soon}} || ||
|-
| {{Tl|bad}} || {{bad}} || {{Tlp|bad|F}} || {{bad|F}}
|-
| {{Tl|eliminated}} || {{eliminated}} || ||
|-
| <code>table-siteactive</code> || {{Tl|Site active}} || {{site active}} || ||
|-
| <code>table-siteinactive</code> || {{Tl|Site inactive}} || {{site inactive}} || ||
|-
|rowspan=6| <code>table-yes2</code> || {{Tl|good}} || {{good}} || {{Tlp|good|A}} || {{good|A}}
|-
| {{Tl|yes2}} || {{yes2}} || {{Tlp|yes2|Text}} || {{yes2|Text}}
|-
| {{Tl|won}} || {{won}} || <nowiki>{{won|text=white|color=darkblue}}</nowiki> || {{won|text=white|color=darkblue}}
|-
| <nowiki>{{won|place=1}}</nowiki> || {{won|place=1}} || <nowiki>{{won|place=Gold}}</nowiki> || {{won|place=Gold}}
|-
| <nowiki>{{won|place=2}}</nowiki> || {{won|place=2}} || <nowiki>{{won|place=Silver}}</nowiki> || {{won|place=Silver}}
|-
| <nowiki>{{won|place=3}}</nowiki> || {{won|place=3}} || <nowiki>{{won|place=Bronze}}</nowiki> || {{won|place=Bronze}}
|-
|rowspan=4| <code>table-no2</code> || {{Tl|no2}} || {{no2}} || {{Tlp|no2|Text}} || {{no2|Text}}
|-
| {{Tl|nom}} || {{nom}} || {{Tlp|nom|5}} || {{nom|5}}
|-
| {{Tl|sho}} || {{sho}} || ||
|-
| {{Tl|TBA}} || {{TBA}} || {{Tlp|TBA|To be announced}} || {{TBA|To be announced}}
|-
|rowspan=4| <code>table-partial</code> || {{Tl|partial}} || {{partial}} || ||
|-
| {{Tl|yes-No}} || {{Yes-No}} || ||
|-
| {{Tl|okay}} || {{okay}} || {{Tlp|okay|C}} || {{okay|C}}
|-
| {{Tl|some}} || {{some}} || ||
|-
| <code>table-any</code> || {{Tl|any}} || {{any}} || ||
|-
|rowspan=2| <code>table-na</code> || {{Tl|n/a}} || {{n/a}} || ||
|-
| {{Tl|BLACK}} || {{BLACK}} || ||
|-
|rowspan=2| <code>table-unknown</code> || {{Tl|dunno}} || {{dunno}} || ||
|-
| {{Tl|Unknown}} || {{Unknown}} || ||
|-
| <code>table-depends</code> || {{Tl|Depends}} || {{Depends}} || {{Tlp|Depends|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{Depends|Customized [[Plain text|text]]}}
|-
| <code>table-included</code> || {{Tl|Included}} || {{Included}} || ||
|-
|rowspan=2| <code>table-dropped</code> || {{Tl|dropped}} || {{dropped}} || ||
|-
| {{Tl|terminated}} || {{terminated}} || ||
|-
|rowspan=2| <code>table-beta</code> || {{Tl|beta}} || {{beta}} || ||
|-
| {{Tl|table-experimental}} || {{table-experimental}} || {{Tlp|table-experimental|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{table-experimental|Customized [[Plain text|text]]}}
|-
| <code>table-free</code> || {{Tl|free}} || {{free}} || {{Tlp|free|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{free|Customized [[Plain text|text]]}}
|-
| <code>table-nonfree</code> || {{Tl|nonfree}} || {{nonfree}} || {{Tlp|nonfree|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{nonfree|Customized [[Plain text|text]]}}
|-
| <code>table-proprietary</code> || {{Tl|proprietary}} || {{proprietary}} || {{Tlp|proprietary|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{proprietary|Customized [[Plain text|text]]}}
|-
| <code>table-needs</code> || {{Tl|needs}} || {{needs}} || {{Tlp|needs|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{needs|Customized [[Plain text|text]]}}
|-
| ''no class'' || {{Tl|incorrect}} || {{incorrect}} || {{Tlp|incorrect|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{incorrect|Customized [[Plain text|text]]}}
|-
| ''no class'' || {{Tl|no result}} || {{No result}} || {{Tlp|no result|N.R.}} || {{No result|N.R.}}
|-
| ''no class'' || {{Tl|pending}} || {{Pending}} || ||
|-
| <code>table-nightly</code> || {{Tl|nightly}} || {{nightly}} || {{Tlp|nightly|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{nightly|Customized [[Plain text|text]]}}
|-
| <code>table-release-candidate</code> || {{Tl|release-candidate}} || {{release-candidate}} || {{Tlp|release-candidate|<nowiki>Customized [[Plain text|text]]</nowiki>}} || {{release-candidate|Customized [[Plain text|text]]}}
|-
| ''no class'' || {{Tl|?}}<ref name="table-cell-templates-table-noparam">Does not take a parameter; not really a table cell template at all, but here for completeness</ref> || {{?}} || ||
|-
| ''no class'' || {{Tl|unofficial}} || {{Unofficial}} || ||
|-
| ''no class'' || {{Tl|usually}} || {{Usually}} || ||
|-
| ''no class'' || {{Tl|rarely}} || {{Rarely}} || ||
|-
| ''no class'' || {{Tl|sometimes}} || {{Sometimes}} || ||
|-
| ''no class'' || {{Tl|draw}} || {{draw}} || {{Tlp|draw|Text}} || {{draw|Text}}
|}

== Code ==

Common code to most if not all the templates in this series:
:<code>{{Table cell templates|class=''automatic''|text=''text''|bg=#''abcdef''}}</code>

Code specific to this template:
:<code>{{ {{BASEPAGENAME}} }}</code>

To make a new table cell template you can use:
<syntaxhighlight lang=text enclose="div">style="background: background color; color: black; vertical-align: middle; text-align: <nowiki>{{{align|</nowiki>standard horizontal alignment<nowiki>}}}</nowiki>; <nowiki>{{{style|}}}</nowiki>" class="a class name without prefix table-a class name without prefix"| <nowiki>{{{1|</nowiki>default text<nowiki>}}}</nowiki></syntaxhighlight>

You should leave out the <code>align</code> parameter and often the <code>class</code> parameter is unnecessary, too.

Add the new template to the table in the [[Template:Table cell templates/doc|common documentation]] afterwards. Please consider reusing one of the other templates and please choose the color sensibly.

If you find a table cell template that does not take a parameter and you want to be able to change the text in the cell, ''do not'' duplicate the template! Instead, edit the template and change the text to a default parameter substitution. For example, if a template's text is <code>Dropped</code>, change that to <code><nowiki>{{{1|Dropped}}}</nowiki></code>.

style="background: #abcdef; color: black; vertical-align: middle; text-align: {{{align|center}}}; {{{style|}}}" class="automatic table-automatic"| {{{1|text}}}
== Usage ==
<templatedata>{
"description": "One of several templates for styling individual table cells with standard contents and colors.",
"params": {
"1": {
"label": "text",
"description": "text to be displayed instead of the default, if this doesn’t work put the text after the template, possibly with a vertical bar | in between",
"type": "string/line",
"default": "(template dependent)",
"required": false
},
"align": {
"label": "horizontal align",
"description": "text alignment inside the cell, either ‘left’, ‘right’, ‘center’ or ‘justified’",
"default": "center",
"inherits": "1"
},
"style": {
"label": "style",
"description": "a semicolon separated list of additional CSS rules to be applied to the table cell",
"default": "",
"inherits": "1"
},
"color": {
"label": "background color",
"description": "a valid CSS color value or name to override the standard the cell background, only available with some templates",
"inherits": "1"
}
}}</templatedata>

== See also ==
* {{Tl|change}}: Calculates, displays and color-codes changes between two values
* {{Tl|GPL-lic}}: Specialized redirect for {{tlf|Free}}
* {{T1|LGPL-lic}}: Specialized redirect for {{tlf|Free}}

== Notes ==
{{Reflist}}

<includeonly>
<!-- ADD CATEGORIES BELOW THIS LINE -->
[[Category:Unified table cell templates]]
</includeonly>

This page has been seen 471 times.

Recent wiki activity

Icon legend

  • Can be used as a template
  • Color code

    • Content has new updates
    • Content has no updates
Top