Appearance
@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
| Color | CSS Class |
|---|---|
GREY | grey |
BLUE_GREY | blue-grey |
LIGHT_GREEN | light-green |
LIGHT_BLUE | light-blue |
ORANGE | orange |
RED | red |
BROWN | brown |
LIME | lime |
INDIGO | indigo |
YELLOW | yellow |
BLACK | black |
PURPLE | purple |
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).