Styling Reference
This page lists every field in AppStyles, its default value, and what it controls. It also covers the two style input formats and provides complete examples.
AppStyle variants
Each style field accepts one of two variants:
| Variant | Input | Example |
|---|---|---|
AppStyle::Markup |
farben markup string | AppStyle::Markup("[bold cyan]") |
AppStyle::Anstyle |
anstyle::Style value |
AppStyle::Anstyle(Style::new().bold()) |
farben markup reference
| Code | Effect |
|---|---|
[bold] |
Bold text |
[italic] |
Italic text |
[underline] |
Underlined text |
[dim] |
Dimmed text |
[black], [red], [green], [yellow], [blue], [magenta], [cyan], [white] |
Standard colors |
[bright_black], [bright_red], etc. |
Bright colors |
[bold cyan] |
Combined effects (space-separated) |
anstyle reference
use anstyle::{Style, AnsiColor};
Style::new()
.fg_color(Some(AnsiColor::Cyan.into()))
.bold()
Style field reference
General help fields
| Field | Default | Affected elements |
|---|---|---|
header |
[bold underline] |
Section headings: "Commands:", "Arguments:", "Options:", "Usage:", "Aliases:" |
brand |
[bold] |
App name and version on --help and --version |
command |
[bold] |
Command and parameter names in listings |
command_header |
[bold] |
Header in per-command help |
usage |
[bold] |
Usage line content in command help |
aliases |
[bold] |
Aliases content in command help |
dim |
[dim] |
Secondary info: defaults, env vars, choices |
deprecated |
[dim] |
Deprecated command names and deprecation banners |
Error fields
| Field | Default | Affected elements |
|---|---|---|
warning |
[yellow] |
Reserved for future use |
error_label |
[bold red] |
The "error" prefix |
error_kind |
(none) | Error type identifier: "unknown command", "missing value" |
error_token |
[yellow] |
Problematic tokens: --version, <target> |
error_pipes |
[bold blue] |
Source line and pipes in error display |
error_highlight |
[bold red] |
Caret (^) highlighting in errors |
hint |
[bold cyan] |
Hint messages like "run 'myapp --help'" |
Complete customization example
use clish::prelude::*;
use clish::help::{AppStyles, AppStyle};
app!()
.name("mycli")
.version("1.0.0")
.description("My CLI tool")
.styles(AppStyles {
// Headers
header: AppStyle::Markup("[bold cyan underline]"),
// Branding
brand: AppStyle::Markup("[bold cyan]"),
// Commands
command: AppStyle::Markup("[bold cyan]"),
command_header: AppStyle::Markup("[bold cyan]"),
// Usage
usage: AppStyle::Markup("[bold]"),
aliases: AppStyle::Markup("[bold]"),
// Secondary info
dim: AppStyle::Markup("[dim]"),
deprecated: AppStyle::Markup("[dim]"),
// Errors
error_label: AppStyle::Markup("[bold red]"),
error_kind: AppStyle::Markup(""),
error_token: AppStyle::Markup("[yellow bold]"),
error_pipes: AppStyle::Markup("[bold blue]"),
error_highlight: AppStyle::Markup("[bold red underline]"),
hint: AppStyle::Markup("[bold cyan]"),
// Default for rest
..Default::default()
})
.run();
Partial customization
Use struct update syntax to change only the fields you care about:
app!()
.styles(AppStyles {
header: AppStyle::Markup("[bold magenta underline]"),
command: AppStyle::Markup("[bold magenta]"),
..Default::default()
})
.run();
anstyle integration
For projects already using anstyle:
use anstyle::{Style, AnsiColor};
app!()
.styles(AppStyles {
header: AppStyle::Anstyle(
Style::new()
.fg_color(Some(AnsiColor::Cyan.into()))
.bold()
),
command: AppStyle::Anstyle(
Style::new()
.fg_color(Some(AnsiColor::Cyan.into()))
),
..Default::default()
})
.run();
Color reference
Standard ANSI colors available in farben markup:
| Color | Bright variant |
|---|---|
black |
bright_black |
red |
bright_red |
green |
bright_green |
yellow |
bright_yellow |
blue |
bright_blue |
magenta |
bright_magenta |
cyan |
bright_cyan |
white |
bright_white |
For RGB colors, use anstyle with specific values.
Best practices
- Consistency: Use the same accent color for headers and commands
- Accessibility: Ensure high contrast between foreground and background
- Clarity: Use
dimfor secondary information that should not compete with primary content - Errors: Keep error text highly visible with bold, bright colors