Primary color (blue) - for primary actions and headers
Raxol. CLI. Colors
(Raxol v2.6.0)
View Source
Centralized color palette for consistent CLI styling.
This module provides a unified color scheme for all terminal output, ensuring visual consistency across mix tasks, the playground, and error messages.
Design Principles
- Semantic colors: Use purpose-based names (
:success,:error) not raw colors - Composable: Functions return ANSI strings that can be concatenated
- Accessible: Reasonable contrast for most terminals
- Consistent: Same meaning everywhere in the CLI
Usage
import Raxol.CLI.Colors
# Inline styling
IO.puts(success("[OK]") <> " Task completed")
IO.puts(error("[FAIL]") <> " Something went wrong")
# With reset
IO.puts(info("Processing...") <> reset())
# Status indicators
IO.puts(status_indicator(:ok) <> " All checks passed")
# Formatted messages
IO.puts(format_success("Build complete"))
IO.puts(format_error("Compilation failed", "missing module Foo"))
Summary
Functions
Accent color (magenta) - for highlighting important items
Apply accent styling to text
Bold text
Apply bold styling to text
Box drawing characters for consistent styling
Dim/faint text
Format a divider line.
Draw a simple box around text.
Error color (red) - for failures and problems
Apply error styling to text
Format a command suggestion.
Format an error message with indicator and optional details.
Format a fix suggestion with command.
Format an info message with indicator.
Format a skip message with indicator.
Format a step in a multi-step process.
Format a success message with indicator.
Format a "Did you mean?" suggestion.
Format a timing result.
Format a warning message with indicator.
Info color (cyan) - for informational messages
Apply info styling to text
Muted color (light black/gray) - for secondary information
Apply muted styling to text
Primary color (blue) - for primary actions and headers
Apply primary styling to text
Reset all formatting
Format a section header.
Returns a formatted status indicator.
Format a subsection header.
Success color (green) - for positive outcomes
Apply success styling to text
Warning color (yellow) - for non-fatal issues
Apply warning styling to text
Functions
Accent color (magenta) - for highlighting important items
Apply accent styling to text
Bold text
Apply bold styling to text
Box drawing characters for consistent styling
Dim/faint text
Format a divider line.
Draw a simple box around text.
Examples
draw_box("Hello World", width: 20)
Error color (red) - for failures and problems
Apply error styling to text
Format a command suggestion.
Examples
format_command("mix raxol check")
# => "mix raxol check" in cyan
Format an error message with indicator and optional details.
Examples
format_error("Compilation failed")
format_error("Compilation failed", "undefined function foo/1")
Format a fix suggestion with command.
Examples
format_fix("Run the formatter", "mix format")
Format an info message with indicator.
Format a skip message with indicator.
Format a step in a multi-step process.
Examples
format_step(1, 5, "Compiling")
# => "[1/5] Compiling"
Format a success message with indicator.
Examples
format_success("Build complete")
# => "[OK] Build complete" with green indicator
Format a "Did you mean?" suggestion.
Examples
format_suggestion("chek", "check")
# => "Did you mean: check?"
Format a timing result.
Examples
format_timing("Compilation", 1234)
# => "Compilation completed in 1.23s"
Format a warning message with indicator.
Info color (cyan) - for informational messages
Apply info styling to text
Muted color (light black/gray) - for secondary information
Apply muted styling to text
Apply primary styling to text
Reset all formatting
Format a section header.
Examples
section_header("Running Tests")
# => "==> Running Tests" in cyan
Returns a formatted status indicator.
Examples
status_indicator(:ok) # => "[OK]" in green
status_indicator(:error) # => "[FAIL]" in red
status_indicator(:warning) # => "[WARN]" in yellow
status_indicator(:skip) # => "[SKIP]" in muted
status_indicator(:info) # => "[INFO]" in cyan
Format a subsection header.
Success color (green) - for positive outcomes
Apply success styling to text
Warning color (yellow) - for non-fatal issues
Apply warning styling to text