Difference between revisions of "Template:Color box/doc"

From blackwiki
Jump to navigation Jump to search
imported>Useddenim
(Shortcuts/Redirects)
imported>Nihiltres
(uses TemplateStyles now)
 
(10 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
 
{{tsh|Colorbox|Colourbox|Colour box|Color square|Legend3}}
 
{{tsh|Colorbox|Colourbox|Colour box|Color square|Legend3}}
 +
{{For2|the templates that display text in a colored box|{{tl|Divbox}} or [[Template:Mbox templates see also]]}}
 +
{{Uses TemplateStyles|Template:Legend/styles.css|noprotcat=yes}}
 
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE -->
  
 
==Usage==
 
==Usage==
<code>&#123;&#123;color box|''color''|''text''|''text color''}}</code>
+
{{Format TemplateData|JSON=
 
 
*Colors are most commonly specified as either a color keyword or as the [[Web colors#Hex triplet|hexadecimal triplet]] representing an RGB combination.  See [[web colors]] for details.
 
*If specified, the <code>text</code> is centered within the box.
 
*If no color is specified for the text, it is displayed using the default style foreground color as prescribed by [[Cascading Style Sheets|CSS]]. For most users this is black.
 
* The optional parameter <code>|border=</code> will change the color of the outline box. The default is black.
 
 
 
{| class="wikitable"
 
|+ '''Examples'''
 
|-
 
! Visual effect !! Markup
 
|-
 
| {{color box|Green}} || <code><nowiki>{{color box|Green}}</nowiki></code>
 
|-
 
| {{color box|Yellow|Default color for this text}} || <code><nowiki>{{color box|Yellow|Default color for this text}}</nowiki></code>
 
|-
 
| {{color box|Blue|White text in a blue box|White}} || <code><nowiki>{{color box|Blue|White text in a blue box|White}}</nowiki></code>
 
|-
 
| {{color box|SteelBlue|'''Using X11 color names'''|Cornsilk}} || <code><nowiki>{{color box|SteelBlue|'''</nowiki>Using [[X11 color names]]<nowiki>'''|Cornsilk}}</nowiki></code>
 
|-
 
| {{color box|#012345|''Using RGB hex triplets''|#FEDCBA}} || <code><nowiki>{{color box|#012345|''</nowiki>Using [[Web colors#Hex triplet|RGB hex triplet]]<nowiki>''|#FEDCBA}}</nowiki></code>
 
|-
 
| {{color box|Yellow|Red|#f00|border=#f00}} || <code><nowiki>{{color box|Yellow|Red|#f00|border=#f00}}</nowiki></code>
 
|}
 
 
 
== Variants ==
 
{{Color box templates}}
 
 
 
== See also ==
 
* {{tl|Infobox color}}, an infobox for the detailed description of a color.
 
* {{tl|Legend}}
 
 
 
== TemplateData ==
 
{{TemplateData header}}
 
<templatedata>
 
 
{
 
{
 
"params": {
 
"params": {
 
"1": {
 
"1": {
 
"label": "Color",
 
"label": "Color",
"description": "Color of the box.",
+
"description": "Background color of the box.",
 
"example": "Green",
 
"example": "Green",
 
"type": "string",
 
"type": "string",
Line 51: Line 19:
 
"2": {
 
"2": {
 
"label": "Text",
 
"label": "Text",
"description": "The text in the box.",
+
"description": "Adds text inside the box; box is otherwise an empty square.",
 
"example": "Hello, world!",
 
"example": "Hello, world!",
 
"type": "string",
 
"type": "string",
Line 60: Line 28:
 
"description": "Sets the color of the text inside the box.",
 
"description": "Sets the color of the text inside the box.",
 
"example": "Yellow",
 
"example": "Yellow",
                        "type": "string",
+
            "type": "string",
"suggested": true
+
"suggested": true,
 +
            "default": "Either black or white; whichever has greater contrast."
 
},
 
},
 
"border": {
 
"border": {
"description": "Adds border outside the box.",
+
            "label": "Border color",
"example": "#FF0"
+
"description": "Sets the color of the border around the box.",
 +
"example": "#FF0",
 +
            "type": "string",
 +
            "default": "black"
 
}
 
}
 
},
 
},
"description": "Adds a rectangular color box.",
+
"description": "<noexport><code>&#123;&#123;color box&#124;''color''&#124;''text''&#124;''text color''&#125;&#125;</code><br></noexport>Adds a rectangular color box. <ul><li>Colors are most commonly specified as either a color keyword or as the [[Web colors#Hex triplet|hexadecimal triplet]] representing an RGB combination.  See the article [[web colors]] for details.</li><li>If specified, the text is centered within the box.</li></ul>",
 
"format": "inline"
 
"format": "inline"
}
+
} }}
</templatedata>
+
 
 +
{| class="wikitable"
 +
|+ '''Examples'''
 +
|-
 +
! Visual effect !! Markup
 +
|-
 +
| {{color box|Green}} || <code><nowiki>{{color box|Green}}</nowiki></code>
 +
|-
 +
| {{color box|Yellow|Default color for this text}} || <code><nowiki>{{color box|Yellow|Default color for this text}}</nowiki></code>
 +
|-
 +
| {{color box|Blue|Default color for this text}} || <code><nowiki>{{color box|Blue|Default color for this text}}</nowiki></code>
 +
|-
 +
| {{color box|SteelBlue|'''Using X11 color names'''|Gold}} || <code><nowiki>{{color box|SteelBlue|'''</nowiki>Using [[X11 color names]]<nowiki>'''|Gold}}</nowiki></code>
 +
|-
 +
| {{color box|#012345|''Using RGB hex triplets''|#FEDCBA}} || <code><nowiki>{{color box|#012345|''</nowiki>Using [[Web colors#Hex triplet|RGB hex triplet]]<nowiki>''|#FEDCBA}}</nowiki></code>
 +
|-
 +
| {{color box|Yellow|Red|#f00|border=#f00}} || <code><nowiki>{{color box|Yellow|Red|#f00|border=#f00}}</nowiki></code>
 +
|-
 +
| {{color box|white|bordercolor like wikitable|border=#A2A9B1}} || <code><nowiki>{{color box|white|bordercolor like wikitable|border=#A2A9B1}} </nowiki></code>
 +
|}
 +
 
 +
== Variants ==
 +
{{Color box templates}}
 +
 
 +
== Supporting template ==
 +
* {{tl|Greater color contrast ratio}}
 +
 
 +
== See also ==
 +
* {{tl|Infobox color}}, an infobox for the detailed description of a color.
 +
* {{tl|Legend}}
  
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |
+
<includeonly>{{Sandbox other|
 
| <!-- CATEGORIES BELOW THIS LINE, PLEASE: -->
 
| <!-- CATEGORIES BELOW THIS LINE, PLEASE: -->
 
[[Category:Color templates]]
 
[[Category:Color templates]]
 
[[Category:Box templates]]
 
[[Category:Box templates]]
  
}}<!--(end #ifeq)--></includeonly>
+
}}</includeonly>

Latest revision as of 20:12, 3 October 2020

Script error: No such module "Uses TemplateStyles".

Usage

This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

TemplateData for Color box

{{color box|color|text|text color}}
Adds a rectangular color box.
  • Colors are most commonly specified as either a color keyword or as the hexadecimal triplet representing an RGB combination. See the article web colors for details.
  • If specified, the text is centered within the box.
ParameterDescriptionTypeStatus
Color1
Background color of the box.
Example
Green
Stringrequired
Text2
Adds text inside the box; box is otherwise an empty square.
Example
Hello, world!
Stringsuggested
Text color3
Sets the color of the text inside the box.
Default
Either black or white; whichever has greater contrast.
Example
Yellow
Stringsuggested
Border colorborder
Sets the color of the border around the box.
Default
black
Example
#FF0
Stringoptional

Format: inline

Examples
Visual effect Markup
  {{color box|Green}}
 Default color for this text  {{color box|Yellow|Default color for this text}}
 Default color for this text  {{color box|Blue|Default color for this text}}
 Using X11 color names  {{color box|SteelBlue|'''Using X11 color names'''|Gold}}
 Using RGB hex triplets  {{color box|#012345|''Using RGB hex triplet''|#FEDCBA}}
 Red  {{color box|Yellow|Red|#f00|border=#f00}}
 bordercolor like wikitable  {{color box|white|bordercolor like wikitable|border=#A2A9B1}}

Variants

Template Description Example
{{Color box}} a small color box with black borders and text color   or  ORANGE 
{{Color box striped}} a striped version     
{{RouteBox}} a borderless version with text color and wikilinks Template:RouteBox
{{Colorbull}} a colored bullet with wikilinks
{{Legend2}} another borderless version   
{{Color sample}} a small color box with black borders
{{Swatch inline}} Template:Swatch inline
{{Background color}} orange
{{Rail color box}} a version with more display options
(part of Module:Adjacent stations)
Template:Rcb, Template:Rcb, etc.
{{Diagonal split color box}} a small color box split diagonally
   
   
, etc.
{{Motor type}} A small color box corresponding to the motor type Template:Motor type, etc.

Supporting template

See also