Raxol.LiveView.Themes (Raxol LiveView v2.6.0)

Copy Markdown View Source

Built-in color themes for the Raxol LiveView terminal renderer.

Each theme is a map of named color slots. Use get/1 to retrieve a theme and to_css_vars/1 to produce a CSS custom-property string suitable for an inline style attribute.

Built-in themes

  • :default -- dark background, light foreground
  • :light -- light background, dark foreground
  • :nord -- Arctic, north-bluish palette
  • :dracula -- popular purple-accented dark theme
  • :synthwave84 -- retro neon synthwave

Example

css = Raxol.LiveView.Themes.to_css_vars(:nord)
# "--raxol-bg: #2e3440; --raxol-fg: #eceff4; ..."

Summary

Functions

Returns the theme map for the given theme name.

Returns a list of all built-in theme names.

Produces a CSS custom-property string for the given theme.

Types

color()

@type color() :: String.t()

theme_map()

@type theme_map() :: %{
  bg: color(),
  fg: color(),
  cursor: color(),
  black: color(),
  red: color(),
  green: color(),
  yellow: color(),
  blue: color(),
  magenta: color(),
  cyan: color(),
  white: color(),
  bright_black: color(),
  bright_red: color(),
  bright_green: color(),
  bright_yellow: color(),
  bright_blue: color(),
  bright_magenta: color(),
  bright_cyan: color(),
  bright_white: color()
}

Functions

get(theme_name)

@spec get(atom()) :: theme_map()

Returns the theme map for the given theme name.

Falls back to :default when the name is not recognised.

Examples

iex> theme = Raxol.LiveView.Themes.get(:nord)
iex> theme.bg
"#2e3440"

iex> Raxol.LiveView.Themes.get(:unknown) == Raxol.LiveView.Themes.get(:default)
true

list()

@spec list() :: [atom()]

Returns a list of all built-in theme names.

Examples

iex> :default in Raxol.LiveView.Themes.list()
true

to_css_vars(theme_name)

@spec to_css_vars(atom()) :: String.t()

Produces a CSS custom-property string for the given theme.

The returned string is suitable for use in an inline style attribute and sets --raxol-bg, --raxol-fg, --raxol-cursor, plus all 16 named color properties.

Examples

iex> css = Raxol.LiveView.Themes.to_css_vars(:default)
iex> css =~ "--raxol-bg:"
true