Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/spatialillusions/milsymbol/llms.txt

Use this file to discover all available pages before exploring further.

Milsymbol uses a color mode system to map symbol affiliation to fill color. Rather than hard-coding a single color per symbol, a ColorMode object is a named palette that defines one color for each of the six possible affiliations: Civilian, Friend, Hostile, Neutral, Unknown, and Suspect. When a symbol is rendered, milsymbol looks up the affiliation of the SIDC and reads the matching color from the active mode. This means you can switch the entire visual vocabulary of your map from a light theme to a dark theme by changing a single string.

Affiliation-to-Color Mapping

Military standards assign colors to affiliations. Milsymbol follows MIL-STD-2525 / APP-6 conventions by default:
AffiliationStandard colorMeaning
FriendBlueAllied or own forces
HostileRedEnemy forces
NeutralGreenNeither hostile nor friendly
UnknownYellowAffiliation not yet established
CivilianPurpleNon-military civilian entities
SuspectAmberPotentially hostile; confirmed in 2525E
The exact shade of blue (or red, green, yellow, purple, amber) depends on the active color mode.

Built-In Color Modes

When milsymbol initialises, nine color modes are registered automatically. You can use any of their names as the colorMode string option:
NameDescription
LightBright, pastel-style fill colors — the default mode
MediumSaturated mid-tone colors; good contrast on light backgrounds
DarkDeep, muted colors suited to dark-themed map canvases
FrameColorThe exact frame-outline colors; useful for unframed symbols
IconColorBright, fully-saturated colors for icon strokes
BlackAll affiliations render black — for single-color printing
WhiteAll affiliations render white
OffWhitergb(239,239,239) for all affiliations; used for white icon parts
Nonefalse for all affiliations — transparent / no fill

Light, Medium, and Dark RGB Values

The following RGB values are taken directly from src/colormodes.js:
// src/colormodes.js — Light
{
  Civilian: "rgb(255,161,255)",  // pale purple
  Friend:   "rgb(128,224,255)",  // light blue
  Hostile:  "rgb(255,128,128)",  // light red
  Neutral:  "rgb(170,255,170)",  // light green
  Unknown:  "rgb(255,255,128)",  // light yellow
  Suspect:  "rgb(255,229,153)",   // pale amber
}

Setting the Color Mode on a Symbol

Pass the mode name as the colorMode style option when constructing a symbol, or update it later with setOptions():
// Light fill (default)
const sym1 = new ms.Symbol("SFG-UCI----D", { colorMode: "Light" });

// Dark fill for a dark-map theme
const sym2 = new ms.Symbol("SFG-UCI----D", { colorMode: "Dark" });

// Switch a live symbol to Medium
sym1.setOptions({ colorMode: "Medium" });

// Pass a ColorMode object directly instead of a string
const myMode = ms.ColorMode(
  "purple", "blue", "red", "green", "yellow", "orange"
);
const sym3 = new ms.Symbol("SFG-UCI----D", { colorMode: myMode });

ms.ColorMode() — Creating a Custom Palette

ms.ColorMode(civilian, friend, hostile, neutral, unknown, suspect) constructs a plain ColorMode object. The arguments are CSS color strings (keywords, rgb(...), hex, etc.) in affiliation order:
// Function signature (from index.d.ts)
ms.ColorMode(
  civilian: string,
  friend:   string,
  hostile:  string,
  neutral:  string,
  unknown:  string,
  suspect:  string
): ColorMode
Returns:
{
  Civilian: string,
  Friend:   string,
  Hostile:  string,
  Neutral:  string,
  Unknown:  string,
  Suspect:  string
}

Example — High-Contrast Custom Mode

import ms from "milsymbol";

// Create a high-contrast mode suitable for printed maps
const printMode = ms.ColorMode(
  "#cc00cc",  // Civilian
  "#003399",  // Friend
  "#cc0000",  // Hostile
  "#007700",  // Neutral
  "#999900",  // Unknown
  "#cc6600"   // Suspect
);

const sym = new ms.Symbol("SFG-UCI----D", {
  colorMode: printMode,
  size: 60,
});

ms.setColorMode(name, colormode) — Registering a Mode Globally

Register a named color mode so you can reference it by string across all symbol instances:
// Signature
ms.setColorMode(name: string, colormode: ColorMode): ColorMode
// Register "Print" globally
const printMode = ms.ColorMode(
  "#cc00cc", "#003399", "#cc0000", "#007700", "#999900", "#cc6600"
);
ms.setColorMode("Print", printMode);

// Now any symbol can use the name string
const sym = new ms.Symbol("SFG-UCI----D", { colorMode: "Print" });
Calling setColorMode with the name of a built-in mode (e.g. "Light") overrides that mode globally for the session.

ms.getColorMode(name) — Retrieving a Registered Mode

// Signature
ms.getColorMode(mode: string): ColorMode
const light = ms.getColorMode("Light");
console.log(light.Friend); // "rgb(128,224,255)"

const dark = ms.getColorMode("Dark");
console.log(dark.Hostile); // "rgb(200,0,0)"
This is useful when you want to clone and modify an existing mode rather than building one from scratch:
// Clone Light and desaturate Unknown
const softMode = { ...ms.getColorMode("Light") };
softMode.Unknown = "rgb(230,230,180)";
ms.setColorMode("Soft", softMode);

Full Custom Mode Workflow

1

Create the ColorMode object

const nightMode = ms.ColorMode(
  "rgb(120, 0, 120)",   // Civilian
  "rgb(0, 80, 160)",    // Friend
  "rgb(160, 0, 0)",     // Hostile
  "rgb(0, 120, 0)",     // Neutral
  "rgb(160, 160, 0)",   // Unknown
  "rgb(180, 100, 0)"    // Suspect
);
2

Register it with a name

ms.setColorMode("Night", nightMode);
3

Use it on symbols

const sym = new ms.Symbol("130310001412110000000000000000", {
  colorMode: "Night",
  size: 40,
});
document.body.appendChild(sym.asDOM());

Additional Color Options

civilianColor

When true (the default), civilian symbols use the Civilian key of the active color mode instead of the affiliation color:
// Default: civilian symbols show purple
const sym = new ms.Symbol("SFGPUCI---E", { civilianColor: true });

// Disable: civilian symbols use the standard affiliation color (e.g. blue for Friend)
const sym2 = new ms.Symbol("SFGPUCI---E", { civilianColor: false });

monoColor

Setting monoColor switches the symbol to a single-color unstroked rendering — useful for icon legends or accessibility modes:
// Render entire symbol in black — no fill, just outline color
const sym = new ms.Symbol("SFG-UCI----D", {
  monoColor: "black",
  size: 40,
});

// Dark grey monochrome
const sym2 = new ms.Symbol("SHG-UCI----D", {
  monoColor: "rgb(60,60,60)",
  size: 40,
});
When monoColor is set, fill is forced to false internally and colorMode is ignored.

fillColor

fillColor accepts any CSS color string and overrides the fill for the symbol frame — bypassing the affiliation lookup in the active color mode entirely:
// Force all symbols to teal regardless of affiliation
const sym = new ms.Symbol("SFG-UCI----D", {
  fillColor: "teal",
  size: 40,
});
Use colorMode when you want affiliation-aware coloring (the standard military convention). Use fillColor only when you need a direct override that ignores affiliation — for example, rendering a cluster icon in your app’s brand color rather than a tactical color.

frameColor and iconColor

Both accept either a ColorMode object or a CSS string:
// Custom frame outline color
const sym = new ms.Symbol("SFG-UCI----D", {
  colorMode: "Light",
  frameColor: ms.ColorMode("black","black","black","black","black","black"),
  iconColor: ms.ColorMode("black","black","black","black","black","black"),
});

Build docs developers (and LLMs) love