Boxart.Theme (Boxart v0.3.2)

Copy Markdown View Source

Color themes for terminal diagram output.

Maps semantic style keys (:node, :edge, :arrow, etc.) to IO.ANSI format sequences. Use built-in themes or define your own.

Built-in themes

  • :default — cyan nodes, yellow arrows, dim edges
  • :mono — white/gray, no color
  • :neon — magenta nodes, green arrows
  • :dracula — purple/green on dark background
  • :nord — cool blues and greens
  • :amber — warm amber/gold tones
  • :phosphor — green terminal aesthetic

Custom themes

my_theme = %Boxart.Theme{
  node: [:blue],
  edge: [:white],
  arrow: [:red, :bright],
  label: [:bright],
  edge_label: [:faint, :italic]
}

Boxart.render(graph, theme: my_theme)

Summary

Functions

Returns a built-in theme by name.

Returns the ANSI format sequence for a style key.

Converts the theme to a map of style key => ANSI atoms. Useful for precomputing.

Types

ansi_style()

@type ansi_style() :: [atom()]

t()

@type t() :: %Boxart.Theme{
  arrow: ansi_style(),
  dim: ansi_style(),
  edge: ansi_style(),
  edge_label: ansi_style(),
  label: ansi_style(),
  node: ansi_style(),
  subgraph: ansi_style(),
  subgraph_label: ansi_style()
}

Functions

get(name)

@spec get(atom()) :: t()

Returns a built-in theme by name.

style_for(theme, key)

@spec style_for(t(), String.t()) :: ansi_style()

Returns the ANSI format sequence for a style key.

to_map(theme)

@spec to_map(t()) :: %{required(String.t()) => ansi_style()}

Converts the theme to a map of style key => ANSI atoms. Useful for precomputing.