Skip to main content

Rich supports colors.

Project description

Rich Color Support

A Python library providing curated color palettes for rich terminal applications with descriptive color names.

Features

  • Multiple Color Sets: Choose from 8, 16, 32, 64, or the full palette of 200+ colors
  • Descriptive Names: Easy-to-remember color names like NAVY_BLUE, HOT_PINK, CHARTREUSE
  • Color Rotation: Built-in color rotator for cycling through colors without repetition
  • Rich Integration: Designed to work seamlessly with the Rich library

Installation

pip install rich-color-support

Quick Start

from rich_color_support import RichColors8, RichColors16, get_color_set, RichColorRotator
from rich.console import Console

console = Console()

# Use predefined color sets
console.print("Hello World!", style=f"color {RichColors8.RED}")
console.print("Colorful text!", style=f"color {RichColors16.CHARTREUSE}")

# Get a dynamic color set
colors = get_color_set(32)
for i, color in enumerate(colors):
    console.print(f"Line {i}", style=f"color {color}")

# Use color rotator for automatic cycling
rotator = RichColorRotator(8)
for i in range(20):
    color = rotator.pick()
    console.print(f"Message {i}", style=f"color {color}")

What's new in v0.2.0

Semantic colors and themes

from rich.console import Console
from rich_color_support import SemanticColors, dark_theme

console = Console(theme=dark_theme())
console.print("[success]Build passed[/]")
console.print(f"[{SemanticColors.ERROR}]Tests failed[/]")

Eight themes are available: default_theme, dark_theme, light_theme, high_contrast_theme, monochrome_theme, colorblind_theme (Okabe-Ito inspired), pastel_theme, monokai_theme. Use build_theme() for partial overrides.

Filter helpers

from rich_color_support import RichColors, filter_colors

dark_blues = filter_colors(RichColors, hue="blue", brightness="dark")
vivid_warm = filter_colors(RichColors, temperature="warm", saturation="vivid")

Preview and CLI

python -m rich_color_support preview --hue blue
python -m rich_color_support themes
python -m rich_color_support theme dark --demo

Color Sets

Class Colors Description
RichColors8 8 Essential high-contrast colors
RichColors16 16 Popular well-distinguished colors
RichColors32 32 Readable colors for rich interfaces
RichColors64 64 Professional colors for advanced apps
RichColors 200+ Complete palette of descriptive colors

Usage Examples

Basic Color Usage

from rich_color_support import RichColors16
from rich.console import Console

console = Console()

# Direct color usage
console.print("Error message", style=f"color {RichColors16.RED}")
console.print("Success message", style=f"color {RichColors16.GREEN}")
console.print("Warning message", style=f"color {RichColors16.YELLOW}")

Dynamic Color Selection

from rich_color_support import get_color_set

# Get exactly 10 colors
colors = get_color_set(10)

# Get colors for many items (returns full palette if > 64)
colors = get_color_set(100)

Color Rotation

from rich_color_support import RichColorRotator

# Create rotator with 16 colors
rotator = RichColorRotator(16)

# Colors won't repeat until all 16 are used
for item in my_items:
    color = rotator.pick()
    console.print(item, style=f"color {color}")

API Reference

Color Classes

All color classes inherit from RichColorsBase (which extends StrEnum):

  • RichColors8: RED, GREEN, BLUE, YELLOW, MAGENTA, CYAN, WHITE, ORANGE
  • RichColors16: Adds BRIGHT_RED, DARK_GREEN, ROYAL_BLUE, GOLD, PURPLE, DARK_CYAN, LIGHT_CORAL, CHARTREUSE
  • RichColors32: Adds 16 more colors including NAVY_BLUE, HOT_PINK, VIOLET, SALMON
  • RichColors64: Adds 32 more professional colors
  • RichColors: Complete palette with 200+ descriptive color names

Functions

get_color_set(size: int) -> List[RichColorsBase]

Returns a color set of the specified size:

  • size <= 8: Returns subset of RichColors8
  • size <= 16: Returns RichColors16
  • size <= 32: Returns RichColors32
  • size <= 64: Returns RichColors64
  • size > 64: Returns complete RichColors palette

Classes

RichColorRotator(size: int)

A utility class for cycling through colors without repetition.

Methods:

  • pick() -> RichColorsBase: Returns next color in rotation, reshuffles when exhausted

Requirements

  • Python 3.11+
  • Rich 13.0.0+

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rich_color_support-0.2.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rich_color_support-0.2.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file rich_color_support-0.2.0.tar.gz.

File metadata

  • Download URL: rich_color_support-0.2.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Darwin/25.3.0

File hashes

Hashes for rich_color_support-0.2.0.tar.gz
Algorithm Hash digest
SHA256 02e1966084839c84a1ba9ae72eef749842589172bc21d39fe3ec7598441d8ad2
MD5 aa7b52f7e7e81dbcdca7d1f715838a62
BLAKE2b-256 0fea16340d6bf94870fef945769acc82b1ab8a1bf5fe7c9f23558a0c19ae8b94

See more details on using hashes here.

File details

Details for the file rich_color_support-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rich_color_support-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Darwin/25.3.0

File hashes

Hashes for rich_color_support-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df1198cc7275bb2ecf0605aabae508bb79dd47ff9793d97c993383da41fa73e9
MD5 3be929440d8a5c561c2fab0e02b157d2
BLAKE2b-256 7a1b64be4e7f56b4ed1c4f0bf79b21cbecd8665d302adca8b977be3ae9bf9528

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page