Why Vargula?

Overview

This document provides an honest comparison between Vargula and popular Python terminal styling libraries. Each library has its strengths, and the best choice depends on your specific needs.


Quick Comparison Table

Feature

Vargula

Rich

Colorama

Termcolor

Pastel

Basic Text Styling

Markup/Tag Syntax

Background Color Tags

⚠️

⚠️

Tables

Progress Bars

Color Palette Generation

⚠️

Color Theory Schemes

WCAG Accessibility

Colorblind Simulation

Color Manipulation

Theme Support

Cross-platform

Panels/Layout

Syntax Highlighting

Markdown Rendering

Tree Views

Live Display

⚠️

✔ Full support

⚠️ Partial/basic support

✗ Not available


Side-by-Side: “Hello World” Example

Let’s compare how each library handles a simple task: bold red “Hello” and italic blue “World” on the same line.

Vargula

from vargula import Vargula

vg = Vargula()

# Method 1: Using markup tags (most intuitive)
vg.write("<bold><red>Hello</red></bold> <italic><blue>World</blue></italic>")

# Method 2: Using format()
print(vg.format("<bold><red>Hello</red></bold> <italic><blue>World</blue></italic>"))

# Method 3: Using style() function
hello = vg.style("Hello", color="red", look="bold")
world = vg.style("World", color="blue", look="italic")
print(f"{hello} {world}")

# Method 4: Custom styles (reusable)
vg.create("hello_style", color="red", look="bold")
vg.create("world_style", color="blue", look="italic")
vg.write("<hello_style>Hello</hello_style> <world_style>World</world_style>")

Lines of code: 1 line (markup) to 3 lines (custom styling)
Readability: ⭐⭐⭐⭐⭐ Excellent (HTML-like tags are intuitive)
Reusability: ⭐⭐⭐⭐⭐ Excellent (custom styles, themes)


Rich

from rich import print

# Method 1: Using markup tags
print("[bold red]Hello[/bold red] [italic blue]World[/italic blue]")

# Method 2: Using style strings
print("[bold red]Hello[/] [italic blue]World[/]")

# Method 3: Using Text objects
from rich.text import Text
text = Text()
text.append("Hello", style="bold red")
text.append(" ")
text.append("World", style="italic blue")
print(text)

# Method 4: Using Console with style
from rich.console import Console
console = Console()
console.print("Hello", style="bold red", end=" ")
console.print("World", style="italic blue")

Lines of code: 1 line (markup) to 6 lines (Text objects)
Readability: ⭐⭐⭐⭐ Very Good (bracket syntax is clear)
Reusability: ⭐⭐⭐⭐⭐ Excellent (themes, styles, Text objects)


Colorama

from colorama import Fore, Style, init
init()

# Method 1: Manual concatenation (only way)
print(Style.BRIGHT + Fore.RED + "Hello" + Style.RESET_ALL + " " + 
      Style.DIM + Fore.BLUE + "World" + Style.RESET_ALL)

# Method 2: With variables (cleaner)
hello = f"{Style.BRIGHT}{Fore.RED}Hello{Style.RESET_ALL}"
world = f"{Style.DIM}{Fore.BLUE}World{Style.RESET_ALL}"
print(f"{hello} {world}")

# Note: Colorama doesn't have italic support on all platforms
# Using DIM as closest alternative

Lines of code: 2-3 lines
Readability: ⭐⭐ Fair (lots of constants, manual reset)
Reusability: ⭐⭐ Fair (need to define each combination)
Issue: No italic support, must use alternatives


Termcolor

from termcolor import colored

# Method 1: Function calls
hello = colored("Hello", "red", attrs=["bold"])
world = colored("World", "blue", attrs=["italic"])
print(f"{hello} {world}")

# Method 2: Inline (less readable)
print(colored("Hello", "red", attrs=["bold"]) + " " + 
      colored("World", "blue", attrs=["italic"]))

# Method 3: ANSI codes directly (not recommended)
from termcolor import COLORS, ATTRIBUTES
# More complex, not shown for brevity

Lines of code: 2-3 lines
Readability: ⭐⭐⭐ Good (function calls are clear)
Reusability: ⭐⭐ Fair (need wrapper functions for common styles)


Pastel

from pastel import colorize

# Method 1: Using tags
print(colorize('<fg=red;options=bold>Hello</> <fg=blue;options=italic>World</>'))

# Method 2: Multiple colorize calls
hello = colorize('<fg=red;options=bold>Hello</>')
world = colorize('<fg=blue;options=italic>World</>')
print(f"{hello} {world}")

# Method 3: Using style definitions
from pastel import Pastel
pastel = Pastel()
pastel.add_style('hello_style', 'red', options=['bold'])
pastel.add_style('world_style', 'blue', options=['italic'])
print(pastel.colorize('<hello_style>Hello</> <world_style>World</>'))

Lines of code: 1-4 lines
Readability: ⭐⭐⭐ Good (XML-like tags with attributes)
Reusability: ⭐⭐⭐⭐ Very Good (style definitions)


Comparison Summary

Code Clarity (Best to Worst)

  1. Vargula: <bold><red>Hello</red></bold> <italic><blue>World</blue></italic>

    • Nested tags are intuitive, mirrors HTML

  2. Rich: [bold red]Hello[/] [italic blue]World[/]

    • Compact bracket syntax, space-separated attributes

  3. Pastel: <fg=red;options=bold>Hello</> <fg=blue;options=italic>World</>

    • XML-like with attributes, slightly verbose

  4. Termcolor: colored("Hello", "red", attrs=["bold"]) + " " + colored("World", "blue", attrs=["italic"])

    • Function-based, explicit but verbose for complex styles

  5. Colorama: Style.BRIGHT + Fore.RED + "Hello" + Style.RESET_ALL + " " + Style.DIM + Fore.BLUE + "World" + Style.RESET_ALL

    • Manual ANSI code management, most verbose


Readability Score

Library

Single Line

Multi-Style

Nested Styles

Reusability

Vargula

⭐⭐⭐⭐⭐

⭐⭐⭐⭐⭐

⭐⭐⭐⭐⭐

⭐⭐⭐⭐⭐

Rich

⭐⭐⭐⭐⭐

⭐⭐⭐⭐

⭐⭐⭐⭐

⭐⭐⭐⭐⭐

Pastel

⭐⭐⭐⭐

⭐⭐⭐

⭐⭐⭐

⭐⭐⭐⭐

Termcolor

⭐⭐⭐

⭐⭐⭐

⭐⭐

⭐⭐

Colorama

⭐⭐

⭐⭐

⭐⭐


Character Count Comparison

Vargula:     66 chars  |  <bold><red>Hello</red></bold> <italic><blue>World</blue></italic>
Rich:        50 chars  |  [bold red]Hello[/] [italic blue]World[/]
Pastel:      75 chars  |  <fg=red;options=bold>Hello</> <fg=blue;options=italic>World</>
Termcolor:   93 chars  |  colored("Hello","red",attrs=["bold"])+" "+colored("World","blue",attrs=["italic"])
Colorama:   109 chars  |  Style.BRIGHT+Fore.RED+"Hello"+Style.RESET_ALL+" "+Style.DIM+Fore.BLUE+"World"+Style.RESET_ALL

Rich wins for brevity, but Vargula’s nested structure is more intuitive for complex styling.


Complex Nesting Example

What if we want: Bold red “Hello” with underlined “World” all in italic?

Vargula

vg.write("<italic><bold><red>Hello</red></bold> <underline>World</underline></italic>")

Natural nesting, clear hierarchy

Rich

print("[italic][bold red]Hello[/] [underline]World[/][/]")

Works well, though closing tags can stack

Pastel

print(colorize('<options=italic><fg=red;options=bold>Hello</> <options=underline>World</></options=italic>'))

⚠️ Gets complex with multiple option combinations

Termcolor

hello = colored("Hello", "red", attrs=["italic", "bold"])
world = colored("World", attrs=["italic", "underline"])
print(f"{hello} {world}")

⚠️ Loses nesting context, must repeat “italic” on both

Colorama

print(Style.BRIGHT + Fore.RED + "\x1b[3m" + "Hello" + Style.RESET_ALL + 
      "\x1b[3m\x1b[4m" + "World" + Style.RESET_ALL)

Very difficult, need manual ANSI codes for italic


Winner by Category

Category

Winner

Reason

Simplicity

Vargula

Fewest concepts to learn

Brevity

Rich

Shortest syntax for common cases

Nesting

Vargula

Most intuitive nested structure

Readability

Vargula / Rich

Both use clear markup

Flexibility

Rich

Most features overall

Color Focus

Vargula

Best color manipulation tools


vs. Rich

Rich is the most feature-rich terminal library with exceptional layout and formatting capabilities.

Where Rich Excels

  • Advanced Layout: Panels, columns, complex nested layouts

  • Syntax Highlighting: Built-in code highlighting for 300+ languages

  • Markdown Rendering: Full markdown support with formatting

  • Tree Views: File trees and hierarchical data display

  • Logging: Deep integration with Python logging

  • Inspect/Pretty Print: Beautiful object inspection

  • Live Display: Real-time updating displays

  • Console API: Comprehensive console management

  • Maturity: Battle-tested, widely adopted (40K+ GitHub stars)

Where Vargula Excels

  • Color Theory: Built-in palette generation with 7 harmony schemes

  • Accessibility Focus: WCAG contrast checking and colorblind simulation

  • Color Manipulation: Lighten, darken, saturate, shift hue, mix colors

  • Simpler API: Lighter learning curve for basic styling

  • Background Tag Syntax: Intuitive <@color> convention for backgrounds

  • Accessible Theme Generation: Automatic WCAG-compliant themes

  • Palette Persistence: Save/load color schemes as JSON

  • Smaller Footprint: Fewer dependencies, lighter weight

When to Choose Each

  • Choose Rich if: You need advanced layouts, syntax highlighting, markdown rendering, or comprehensive terminal UI features

  • Choose Vargula if: You prioritize color design, accessibility, palette generation, or need a simpler API for styling

Example Comparison

# Rich - Advanced layout
from rich.console import Console
from rich.panel import Panel
from rich.columns import Columns

console = Console()
console.print(Panel("Content", title="Title"))
console.print(Columns([Panel("A"), Panel("B")]))

# Vargula - Color-focused design
import vargula as vg

# Generate accessible theme
theme = vg.generate_accessible_theme("#3498db", wcag_level="AA")
vg.apply_palette_theme(theme)

# Validate for colorblindness
colors = vg.generate_palette("#3498db", "triadic", 5)
is_safe, problems = vg.validate_colorblind_safety(colors)

vs. Colorama

Colorama is a minimalist library focused on cross-platform ANSI color support.

Where Colorama Excels

  • Windows Support: Primary focus on making ANSI work on Windows

  • Stability: Mature, stable, rarely changes

  • Wide Adoption: Used by many major projects

  • No Dependencies: Pure Python, minimal footprint

Where Vargula Excels

  • Rich Styling: Tables, progress bars, markup syntax

  • Color Theory: Palette generation and color harmonies

  • Accessibility: WCAG and colorblind support

  • Color Manipulation: Full color transformation toolkit

  • Modern API: Tag syntax, themes, custom styles

  • Advanced Features: Multi-progress, color mixing, contrast checking

When to Choose Each

  • Choose Colorama if: You only need basic ANSI support with minimal overhead

  • Choose Vargula if: You want modern styling features, color design tools, or accessibility support

Example Comparison

# Colorama - Basic styling
from colorama import Fore, Back, Style

print(Fore.RED + 'Error!' + Style.RESET_ALL)
print(Back.GREEN + Fore.BLACK + 'Success' + Style.RESET_ALL)

# Vargula - Modern markup + color theory
import vargula as vg

vg.write("<red>Error!</red>")
vg.write("<@green><black>Success</black></@green>")


vs. Termcolor

Termcolor provides simple colored text output with attribute support.

Where Termcolor Excels

  • Attributes: Easy bold, underline, blink combinations

  • Lightweight: Very small codebase

  • Established: Long history, stable API

Where Vargula Excels

  • Markup Syntax: HTML-like tags vs function calls

  • Tables & Progress: Built-in rich components

  • Color Theory: Palette generation and harmonies

  • Hex Colors: Direct hex color support

  • Accessibility: WCAG and colorblind tools

  • Themes: Reusable style definitions

  • Color Manipulation: Transform colors programmatically

When to Choose Each

  • Choose Termcolor if: You need a simple drop-in solution for colored output

  • Choose Vargula if: You want markup syntax, advanced color features, or accessibility tools

Example Comparison

# Termcolor - Function-based
from termcolor import colored

print(colored('Error!', 'red', attrs=['bold']))
print(colored('Warning', 'yellow', 'on_red'))

# Vargula - Markup-based
import vargula as vg

vg.write("<bold><red>Error!</red></bold>")
vg.write("<@red><yellow>Warning</yellow></@red>")


vs. Pastel

Pastel focuses on color manipulation and styling with a fluent API.

Where Pastel Excels

  • Color Manipulation: Core strength in color transformations

  • Fluent API: Chainable color operations

  • HSL Support: Direct HSL color handling

  • Poetry Integration: From the Poetry project author

Where Vargula Excels

  • Palette Generation: 7 color harmony schemes

  • Accessibility: WCAG contrast and colorblind simulation

  • Rich Components: Tables and progress bars

  • Markup Syntax: Tag-based formatting

  • Theme System: Complete theme management

  • Validation: Colorblind safety checking

  • More Schemes: Triadic, tetradic, square, split-complementary

When to Choose Each

  • Choose Pastel if: You primarily need color manipulation with a fluent API

  • Choose Vargula if: You need color generation, accessibility validation, or rich terminal components

Example Comparison

# Pastel - Fluent color manipulation
from pastel import colorize

print(colorize('<fg=red;options=bold>Error!</>'))

# Vargula - Color theory + accessibility
import vargula as vg

# Generate accessible, colorblind-safe theme
theme = vg.generate_accessible_theme(
    "#3498db",
    scheme="triadic",
    wcag_level="AA"
)

# Validate for colorblindness
colors = list(theme.values())
is_safe, problems = vg.validate_colorblind_safety(colors, "deuteranopia")

if is_safe:
    vg.apply_palette_theme(theme)
    vg.write("<primary>Accessible colors!</primary>")

Vargula’s Unique Strengths

1. Color Theory Integration

Vargula is the only library with built-in color theory schemes:

from vargula import Vargula

vg = Vargula()

# Seven harmony schemes
schemes = [
    "monochromatic",
    "analogous", 
    "complementary",
    "split_complementary",
    "triadic",
    "tetradic",
    "square"
]

for scheme in schemes:
    colors = vg.generate_palette("#3498db", scheme, 5)
    print(f"\n{scheme.upper()}")
    print(vg.preview_palette(colors))

Use case: Design consistent, harmonious color schemes for your CLI without color theory knowledge.


2. Accessibility First

Only Vargula provides comprehensive accessibility tools:

# WCAG contrast checking
ratio = vg.calculate_contrast_ratio("#FFFFFF", "#000000")
meets_aa = vg.meets_wcag(text_color, bg_color, "AA")

# Automatic contrast fixing
accessible = vg.ensure_contrast(text_color, bg_color, min_ratio=4.5)

# Generate WCAG-compliant themes
theme = vg.generate_accessible_theme(
    "#3498db",
    background="#FFFFFF",
    wcag_level="AAA"
)

# Colorblind simulation
simulated = vg.simulate_colorblindness("#FF0000", "deuteranopia")

# Validate entire palettes
is_safe, problems = vg.validate_colorblind_safety(colors)

Use case: Build CLIs that are accessible to users with visual impairments or color blindness.


3. Intuitive Background Color Syntax

Vargula’s <@color> syntax is cleaner and more intuitive:

# Vargula - symmetric, intuitive
from vargula import Vargula
vg = Vargula()
vg.write("<red>foreground</red>")
vg.write("<@red>background</@red>")
vg.write("<#FF0000>hex foreground</#FF0000>")
vg.write("<@#FF0000>hex background</@#FF0000>")

# Rich - different approaches
from rich import print as rprint
rprint("[red]foreground[/red]")
rprint("[on red]background[/on red]")  # Different syntax

Use case: Consistent, predictable syntax for both foreground and background colors.


4. Complete Color Manipulation Toolkit

base = "#3498db"

# Lightness
lighter = vg.lighten(base, 0.2)
darker = vg.darken(base, 0.2)

# Saturation
saturated = vg.saturate(base, 0.3)
desaturated = vg.desaturate(base, 0.3)

# Hue
shifted = vg.shift_hue(base, 120)  # Blue → Green
inverted = vg.invert(base)

# Mixing
mixed = vg.mix("#FF0000", "#0000FF", 0.5)  # Purple

Use case: Programmatically adjust colors for different states (hover, active, disabled).


5. Palette Persistence

Save and share color schemes:

# Generate and save
colors = vg.generate_palette("#3498db", "triadic", 5)
vg.save_palette(colors, "brand_colors.json", metadata={
    "name": "Brand Colors",
    "created": "2024-11-22"
})

# Load and use
colors, meta = vg.load_palette("brand_colors.json")
vg.apply_palette_theme(colors)

Use case: Share consistent color schemes across team projects or tools.


When to Choose Vargula

Perfect For:

  • ✔ Developers who want simple markup syntax

  • ✔ CLIs requiring accessible, WCAG-compliant colors

  • ✔ Projects needing harmonious color palette generation

  • ✔ Tools targeting colorblind users

  • ✔ Apps requiring consistent color themes

  • ✔ Projects where color design is a priority

May Not Be Ideal For:

  • ✗ Complex terminal layouts (use Rich)

  • ✗ Syntax highlighting code (use Rich)

  • ✗ Markdown rendering (use Rich)

  • ✗ Tree/hierarchical displays (use Rich)

  • ✗ Projects needing absolute minimal dependencies (use Colorama)


Complementary Usage

Vargula and other libraries can work together:

from vargula import Vargula
from rich.console import Console
from rich.panel import Panel

vg = Vargula()
# Generate accessible colors with Vargula
theme = vg.generate_accessible_theme("#3498db", wcag_level="AA")

# Use Rich for layout with Vargula's colors
console = Console()
console.print(Panel(
    vg.format(f"<{theme['primary']}>Content</{theme['primary']}>"),
    title="My Panel"
))

Maturity & Community

Library

GitHub Stars

First Release

Maintainer

Community

Rich

40K+

2019

Textualize

Very Large

Colorama

3.5K+

2010

Jonathan Hartley

Large

Termcolor

600+

2008

Konstantin Lepa

Medium

Pastel

300+

2018

Sébastien Eustace

Small

Vargula

New

2025

Sivaprasad Murali

Growing

Vargula is newer but actively developed with a focus on color theory and accessibility.


Real-World Complex Example

Let’s style a log message: [ERROR] in bold red background, timestamp in dim gray, message in white with file path highlighted in cyan.

Vargula

vg.create("error_label", color="white", bg="red", look="bold")
vg.create("timestamp", color="bright_black", look="dim")
vg.create("filepath", color="cyan", look="underline")

vg.write(
    "<error_label>[ERROR]</error_label> "
    "<timestamp>2024-11-22 10:30:45</timestamp> "
    "Failed to load <filepath>config.yaml</filepath>"
)

Rich

from rich import print

print(
    "[bold white on red][ERROR][/] "
    "[dim bright_black]2024-11-22 10:30:45[/] "
    "Failed to load [cyan underline]config.yaml[/]"
)

Termcolor

from termcolor import colored

error = colored("[ERROR]", "white", "on_red", attrs=["bold"])
time = colored("2024-11-22 10:30:45", "white", attrs=["dark"])
path = colored("config.yaml", "cyan", attrs=["underline"])
print(f"{error} {time} Failed to load {path}")

Colorama

from colorama import Fore, Back, Style

error = f"{Style.BRIGHT}{Fore.WHITE}{Back.RED}[ERROR]{Style.RESET_ALL}"
time = f"{Style.DIM}{Fore.WHITE}2024-11-22 10:30:45{Style.RESET_ALL}"
path = f"{Fore.CYAN}\x1b[4mconfig.yaml{Style.RESET_ALL}"
print(f"{error} {time} Failed to load {path}")

Verdict: Vargula and Rich tie for readability with reusable styles. Rich is more concise inline, Vargula excels with custom style definitions.


The Verdict

Choose Rich if you need:

  • Advanced terminal UI components

  • Syntax highlighting

  • Markdown rendering

  • Complex layouts

  • Maximum features

Choose Colorama if you need:

  • Minimal, stable ANSI support

  • Windows compatibility focus

  • Zero learning curve

  • Absolute smallest footprint

Choose Termcolor if you need:

  • Simple colored output

  • Lightweight solution

  • Established, stable API

Choose Pastel if you need:

  • Fluent color manipulation

  • HSL color operations

  • From Poetry ecosystem

Choose Vargula if you need:

  • Color palette generation

  • Accessibility (WCAG/colorblind)

  • Color theory schemes

  • Intuitive markup syntax

  • Color manipulation toolkit

  • Theme management


Conclusion

Vargula doesn’t try to replace Rich’s comprehensive terminal UI capabilities. Instead, it focuses on being the best tool for color design and accessibility in terminal applications while maintaining minimality.

If you’re building a CLI where:

  • Color choice matters

  • Accessibility is important

  • You want harmonious palettes

  • You need to validate for colorblindness

  • You want simpler markup syntax

Then Vargula is your best choice.

For complex layouts, syntax highlighting, or markdown rendering, Rich remains unmatched. But for color-focused terminal design with accessibility baked in, Vargula offers unique capabilities no other library provides.