Template:Color/doc

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Template:Documentation subpage Template:High-use Template:Warning Template:Uses TemplateStyles Template:Tl can be used to specify the foreground color of a span of text. Acceptable values are RGB hex codes, e.g. #C9E72A, or any of the web colors: red, blue, green, moccasin, darkorchid, etc. To set the background color of a span of text, use Template:Template link.

Usage

For example:

  • {{#invoke:demoTemplate|color|red|Hello, world!}}
  • {{#invoke:demoTemplate|color|#00F000|Hello, world!}}

If the second parameter is omitted, the color value is displayed as text:

  • {{#invoke:demoTemplate|color|#00F000}}
  • {{#invoke:demoTemplate|color|red}}
Using the Codex Design Style Guide for Wikimedia text colors:
  • {{#invoke:demoTemplate|color|var(--color-success, #177860)|Success}}
  • {{#invoke:demoTemplate|color|var(--color-error, #bf3c2c)|Error}}
  • {{#invoke:demoTemplate|color|var(--color-content-added, #006400)|Content added}}
  • {{#invoke:demoTemplate|color|var(--color-content-removed, #8b0000)|Content removed}}

Dark mode

This template does not function in dark mode. If you have a use case for color in your page, you should try to use an existing more-specific template (such as Template:Tl or Template:Tl).

However, if you really need this functionality, you can append a space and !important after the color. For example:

  • {{#invoke:demoTemplate|color|red !important}}

Redirects

See also

TemplateData

Template:TemplateData header <templatedata> { "description": "The color template can be used to add a span of text with any given text color", "params": { "1": { "label": "Color", "description": "CSS name of color or hex code of color, e.g. 'red' or '#00F000'.", "type": "string", "required": true }, "2": { "label": "Text", "description": "The string of text to be formatted in the desired color", "type": "string", "suggested": true } } } </templatedata>