@chromakit/core
    Preparing search index...

    Function color

    • Wrap text with an ANSI foreground color escape sequence.

      Parameters

      • text: string

        The string to style.

      • color: string

        The desired color; hex code or name.

      Returns string

      The ANSI-wrapped text with a foreground color and reset suffix.

      • Parses the given color (hex like #rrggbb, #rgb, or named color) via safeParseColor. If parsing fails, it falls back to white.
      • Emits an ANSI truecolor sequence using rgbToAnsi, e.g. \u001b[38;2;r;g;bm. Terminates the colored portion with ANSI_RESET to avoid bleeding styles.
      • On terminals without 24-bit color support, this may degrade through nearest-color mapping or other fallback behavior as implemented by rgbToAnsi.
      color("Error", "#ff0000"); // red text
      color("Info", "invalid-color"); // falls back to white text

      https://en.wikipedia.org/wiki/ANSI_escape_code — ANSI escape SGR parameters like 38;2;….