Skip to content

Hex Colors#

Disclaimer

Not all terminals support 24-bit colors in RGB, HSL, or Hex. If your terminal does support such advanced colors, read on.

Full Text Functions#

hex(text, hex) #

Prints full line of text in Hex color.

Parameters:

Name Type Description Default
text str

Text to be printed with color.

required
hex str

Hex color value with or without hashtag, for instance #B4FBB8 or B4FBB8, #B4F or B4F.

required
Example
1
2
3
from colorist import hex

hex("I want this text in coral Hex colors", "#ff7f50")

How it appears in the terminal:

% I want this text in coral Hex colors

bg_hex(text, hex) #

Prints full line of text on colored background defined in Hex color.

Parameters:

Name Type Description Default
text str

Text to be printed on colored background.

required
hex str

Hex color value with or without hashtag, for instance #B4FBB8 or B4FBB8, #B4F or B4F.

required
Example
1
2
3
from colorist import bg_hex

bg_hex("I want this background in coral Hex colors", "#ff7f50")

How it appears in the terminal:

% I want this background in coral Hex colors

Custom String Styling#

ColorHex(hex)#

Class for custom foreground text defined in Hex color.

Parameters:

Name Type Description Default
hex str

Hex color value with or without hashtag, for instance #B4FBB8 or B4FBB8, #B4F or B4F.

required
Example
1
2
3
4
5
from colorist import ColorHex

watermelon_red = ColorHex("#ff5733")

print(f"I want to use {watermelon_red}watermelon red{watermelon_red.OFF} color inside this paragraph")

How it appears in the terminal:

% I want to use watermelon red color inside this paragraph

BgColorHex(hex)#

Class for custom background defined in Hex color.

Parameters:

Name Type Description Default
hex str

Hex color value with or without hashtag, for instance #B4FBB8 or B4FBB8, #B4F or B4F.

required
Example
1
2
3
4
5
from colorist import BgColorHex

bg_mint_green = BgColorHex("#99ff99")

print(f"I want to use {bg_mint_green}mint green{bg_mint_green.OFF} background color inside this paragraph")

How it appears in the terminal:

% I want to use mint green background color inside this paragraph