What is the problem this feature will solve?
util.styleText() supports arbitrary foreground colors via hex codes (styleText('#ff5733', text), added in #61556), but there's no equivalent for background colors. Predefined colors already have both a foreground (red) and background (bgRed) variant, but hex colors only cover the foreground case (SGR 38;2;r;g;b).
What is the feature you are proposing to solve the problem?
Extend hex color detection in styleText to also accept a background variant, mirroring the existing bgRed/red naming convention by prefixing the hex code with bg:
styleText('bg#ff5733', 'Warning!');
This would emit the background TrueColor SGR sequence (48;2;r;g;b) instead of the foreground one (38;2;r;g;b), and composes with the existing array syntax to combine foreground + background:
styleText(['#ffffff', 'bg#ff5733'], 'Warning!');
What is the problem this feature will solve?
util.styleText()supports arbitrary foreground colors via hex codes (styleText('#ff5733', text), added in #61556), but there's no equivalent for background colors. Predefined colors already have both a foreground (red) and background (bgRed) variant, but hex colors only cover the foreground case (SGR38;2;r;g;b).What is the feature you are proposing to solve the problem?
Extend hex color detection in
styleTextto also accept a background variant, mirroring the existingbgRed/rednaming convention by prefixing the hex code withbg:This would emit the background TrueColor SGR sequence (
48;2;r;g;b) instead of the foreground one (38;2;r;g;b), and composes with the existing array syntax to combine foreground + background: