classToHex
Commons
stable
Resolves a named colour class string (e.g. "red lighten-2") to its hex value by looking it up in a colour map. Returns an empty string when the colour is not found.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- colorrequiredstring
- A colour class name in the form "colorName modifier" (e.g. "red lighten-2") or just "colorName" for the base shade.
- colorsrequiredRecord<string, Record<string, string>>
- A nested map of colour-name → modifier → hex string. The origam colour palette is the default source.
API
Return value
The value returned by this util.
- The resolved hex string, or an empty string when the colour name or modifier is not found.
Usage
Examples
Ready-to-paste usage snippets.
Resolve a colour class to hex