Colour markup allows you to change the colour of text that appears in the game.
It works in most text fields throughout the game, including:
Mindustry uses a simple bracket-based syntax for colour markup.
The most basic usage of colour markup consists of a pair of square brackets surrounding a colour name, followed by the text that should be coloured.
When using colour markup, the markup syntax itself is “consumed”, leaving behind just the coloured text.
You can use a pair of empty square brackets to “close” the coloured area and return to the previous/original colour.
There are a number of named colours available for use, you can find them listed below:
Code | Preview | Colour |
---|---|---|
[white] | white | #ffffff |
[lightgray] | lightgray | #bfbfbf |
[gray] | gray | #7f7f7f |
[darkgray] | darkgray | #3f3f3f |
[black] | black | #000000 |
[clear] | clear | #00000000 |
[blue] | blue | #0000ff |
[navy] | navy | #000080 |
[royal] | royal | #4169e1 |
[slate] | slate | #708090 |
[sky] | sky | #87ceeb |
[cyan] | cyan | #00ffff |
[teal] | teal | #008080 |
[green] | green | #00ff00 |
[acid] | acid | #7fff00 |
[lime] | lime | #32cd32 |
[forest] | forest | #228b22 |
[olive] | olive | #6b8e23 |
[yellow] | yellow | #ffff00 |
[gold] | gold | #ffd700 |
[goldenrod] | goldenrod | #daa520 |
[orange] | orange | #ffa500 |
[brown] | brown | #8b4513 |
[tan] | tan | #d2b48c |
[brick] | brick | #b22222 |
[red] | red | #ff0000 |
[scarlet] | scarlet | #ff341c |
[crimson] | crimson | #dc143c |
[coral] | coral | #ff7f50 |
[salmon] | salmon | #fa8072 |
[pink] | pink | #ff69b4 |
[magenta] | magenta | #ff00ff |
[purple] | purple | #a020f0 |
[violet] | violet | #ee82ee |
[maroon] | maroon | #b03060 |
[accent] | accent | #ffd37f |
[unlaunched] | unlaunched | #8982ed |
[highlight] | highlight | #ffe0a5 |
[stat] | stat | #ffd37f |
[negstat] | negstat | #e55454 |
Named colours work with either lowercase or uppercase colour names, although not with mixed case. This doesn’t include special colours [accent]
, [unlaunched]
, [highlight]
, [stat]
, and [negstat]
, which only work in lowercase.
The exception to the above rule is with the named colours [lightgray]
and [darkgray]
. When capitalised they must also have an underscore to separate the two words.
Additionally, the named colours [gray]
, [lightgray]
and [darkgray]
, which are spelt using American English, also work with their British English spelling equivalents [grey]
, [lightgrey]
and [darkgrey]
. This also applies to uppercase, using the rule described above.
Hex colours are also available for use in colour markup. These allow for more precise colour control than named colours.
Hex codes represent colours in the format: #RRGGBBAA
RR
is the red valueGG
is the green valueBB
is the blue valueAA
is the alpha/transparency value, this value is optional and defaults to FF
(opaque) if not specifiedHex colours can be used in exactly the same way as named colours, just with the named colour replaced with the hex code, and prefixed with #
.
You can also use a colour with transparency by specifying the alpha value.
Unlike named colours, hex colours are case insensitive.
An empty pair of square brackets can be used to close. This will “close” the most recently added colour and return to the previous colour. As with named/hex colour syntax, closures are consumed when parsed.
Closing is entirely optional, colours will work regardless of if they are closed or not. It can make things simpler however, especially when working within character limits or using deeply-nested colours.
Closures have no effect when no colours are declared before them.
If you want to output the colour markup itself, rather than the coloured text, escaping can be used. To escape colour markup, simply add an extra opening square bracket before your markup syntax. The extra square bracket will be consumed when parsed, leaving behind just the escaped markup.
The same syntax also works for escaping closures.
When using colour markup, colours are “stacked” in the order that they are added.
Colours are added to the stack with either a named or hex colour, and are removed from the stack with a closure.
The same applies when multiple additions of the same colour are used. Each individual colour added is treated as a separate item in the stack.
Transparency is supported, although not in all fields. For example, message blocks support transparency, while multiplayer chat doesn’t.
You can utilise transparency through the named colour ‘clear’ (which is fully transparent) or through alpha values in hex colours.
If transparency is used in a field that doesn’t support it, the colour markup will work as normal except without any transparency shown, just the colour itself.
When using colour markup, errors are silently ignored. This means that if you use the incorrect syntax, the colour markup won’t be consumed and the full text will output without the intended colour/s.
If your colour markup isn’t working properly, check you are using the correct syntax.
Some potential causes of errors include:
Additionally, keep in mind that while colour markup works in most fields throughout the game, it doesn’t work everywhere. For example, some multiplayer servers disable this feature entirely.
While Mindustry doesn’t have built-in support for gradients, you can create gradient effects manually.