Skip to content

@Color

The @Color annotation assigns a visual color to enum values. This is used by the UI to render colored badges, tags, or indicators.

Usage on Enum Values

java
public enum Status {

    @Color(Color.SupportedColor.LIGHT_GREEN)
    IN_STOCK,

    @Color(Color.SupportedColor.YELLOW)
    LOW_STOCK,

    @Color(Color.SupportedColor.RED)
    OUT_OF_STOCK
}

When displayed in the UI, each enum value will be rendered with its assigned color.

Default Color for Enum Types

You can set a default color for all values of an enum by annotating the enum class itself:

java
@Color(Color.SupportedColor.BLUE_GREY)
public enum Priority {
    LOW,
    MEDIUM,
    HIGH
}

All values of Priority will render as BLUE_GREY unless overridden with a field-level @Color annotation on individual values.

WARNING

@Color only has effect on enum values and enum types. Applying it to entity classes (@Entity) has no effect in the UI.

Supported Colors

ColorCSS Class
GREYgrey
BLUE_GREYblue-grey
LIGHT_GREENlight-green
LIGHT_BLUElight-blue
ORANGEorange
REDred
BROWNbrown
LIMElime
INDIGOindigo
YELLOWyellow
BLACKblack
PURPLEpurple

The default color when no @Color annotation is present is GREY.

Target

  • Enum values — most common, used for status indicators
  • Enum types — sets the default color for all values in the enum

The annotation can be placed on ElementType.TYPE (enum classes) and ElementType.FIELD (enum values).