logo MindustryHUB

Colour Markup

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:

  • Multiplayer chat messages
  • Player usernames
  • Message blocks
  • Server status messages

Syntax

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.

[red]this text is red
this text is red

When using colour markup, the markup syntax itself is “consumed”, leaving behind just the coloured text.

[green]this text is green
this text is green

You can use a pair of empty square brackets to “close” the coloured area and return to the previous/original colour.

Some of [blue]this text[] will be blue.
Some of this text will be blue.

Named colours

There are a number of named colours available for use, you can find them listed below:

CodePreviewColour
[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.

[orange]lowercase: this works
lowercase: this works
[ORANGE]uppercase: this also works
uppercase: this also works
[oraNGE]mixed case: this doesn't work
[oraNGE]mixed case: this doesn't work

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.

[LIGHT_GRAY]needs an underscore
needs an underscore
[DARK_GRAY]this also needs an underscore
this also needs an underscore

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.

[lightgray]lightgray[] same as [lightgrey]lightgrey
lightgray same as lightgrey
[gray]gray[] same as [grey]grey
gray same as grey
[darkgray]darkgray[] same as [darkgrey]darkgrey
darkgray same as darkgrey

Hex colours

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 value
  • GG is the green value
  • BB is the blue value
  • AA is the alpha/transparency value, this value is optional and defaults to FF (opaque) if not specified

Hex 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 #.

[#FF0000]red text
red text
[#00FF00]green text
green text
[#0000FF]blue text
blue text

You can also use a colour with transparency by specifying the alpha value.

[#FF0000CC]red with 80% opacity
red with 80% opacity
[#FF000080]red with 50% opacity
red with 50% opacity
[#FF000033]red with ~20% opacity
red with ~20% opacity
[#00000000]fully transparent
fully transparent
[#000000FF]fully opaque
fully opaque

Unlike named colours, hex colours are case insensitive.

[#fa8072]lowercase
lowercase
[#FA8072]uppercase
uppercase
[#Fa8072]mixed case
mixed case

Closing

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.

[tan]before[]after
beforeafter

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.

[tan]First [gold]Second [purple]Third []Second []First
First Second Third Second First

Closures have no effect when no colours are declared before them.

[]this has no effect
this has no effect

Escaping

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.

[forest]a (without escaping, text is coloured)
a (without escaping, text is coloured)
[[forest]a (escaped, text isn't coloured)
[forest]a (escaped, text isn't coloured)

The same syntax also works for escaping closures.

[royal]aa[]aa (this is closed)
aaaa (this is closed)
[royal]aa[[]aa (here the closure is escaped)
aa[]aa (here the closure is escaped)

Concepts

Stacking

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.

a[red]b[gold]c[]d[]e
abcde

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.

a[violet]b[violet]c[]d[]e
abcde

Transparency

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.

[clear]this text is clear
this text is clear
[#FF000088]this text is red, but partially transparent
this text is red, but partially transparent

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.

Troubleshooting

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.

[pirple]this colour name is spelt wrong!
[pirple]this colour name is spelt wrong!
[#xx1234]this is an invalid hex code!
[#xx1234]this is an invalid hex code!

If your colour markup isn’t working properly, check you are using the correct syntax.

Some potential causes of errors include:

  • Missing opening/closing bracket
  • Misspelt/invalid colour name (if using a named colour)
  • Invalid hex code (if using a hex colour)
  • Accidental escape of colour markup syntax

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.

Advanced usage

Gradients

While Mindustry doesn’t have built-in support for gradients, you can create gradient effects manually.

[red]R[#FF4000]a[#FF8000]i[#FFBF00]n[#FFFF00]b[#BFFF00]o[#80FF00]w[#40FF00]!
Rainbow!