Appearance
Directory Structure
Icons are placed under the ICON-LIB directory in your module's resources:
src/main/resources/ICON-LIB/
├── light/
│ └── {fully.qualified.IconGroupName}/
│ └── {category}/
│ └── iconName.svg
└── dark/
└── {fully.qualified.IconGroupName}/
└── {category}/
└── iconName.svgExample:
src/main/resources/ICON-LIB/
├── light/
│ └── consulo.plugin.PluginIconGroup/
│ ├── actions/
│ │ └── close.svg
│ └── nodes/
│ └── module.svg
└── dark/
└── consulo.plugin.PluginIconGroup/
├── actions/
│ └── close.svg
└── nodes/
└── module.svgDirectory Rules
ICON-LIB-- the top-level directory name must be exactlyICON-LIB(all caps).light/dark-- these are the built-in Image Library IDs.lighticons are used with the light theme,darkicons with the dark theme. If a dark variant is not provided, the light icon is used as a fallback.- Icon Group directory -- the directory immediately under
light/ordark/is the Icon Group name. It must be a fully qualified class-like name ending withIconGroup(e.g.,consulo.plugin.PluginIconGroup). - Category directories -- subdirectories within the Icon Group (e.g.,
actions/,nodes/,fileTypes/) organize icons by usage. Category names become method name prefixes in the generated class.
Maven Plugin Configuration
The maven-consulo-plugin generates a typed Java Icon Group class from the ICON-LIB directory structure. Add the following to your pom.xml:
xml
<build>
<plugins>
<plugin>
<groupId>consulo.maven</groupId>
<artifactId>maven-consulo-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate-icon</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>The generated class is written to target/generated-sources/icon/.
Generated Icon Group Class
For the example structure above, the plugin generates:
java
package consulo.plugin;
import consulo.ui.image.ImageKey;
public final class PluginIconGroup {
public static final String ID = "consulo.plugin.PluginIconGroup";
private static final ImageKey actions_close = ImageKey.of(ID, "actions.close", 16, 16);
private static final ImageKey nodes_module = ImageKey.of(ID, "nodes.module", 16, 16);
public static ImageKey actionsClose() {
return actions_close;
}
public static ImageKey nodesModule() {
return nodes_module;
}
}Naming Convention
- Category directories become method name prefixes:
actions/close.svggeneratesactionsClose(). - The SVG
widthandheightattributes determine theImageKeydimensions. ImageKeyimplementsImageand is created viaImageKey.of(groupId, imageId, width, height).
Icon Format
- SVG is the recommended format. The
widthandheightattributes in the SVG file set the base icon size. - PNG is also supported. Provide
@2xvariants for HiDPI displays.