Themes
About 1175 words
A theme defines how unifi-cli looks: the colors for dark and for light terminals, the border style, and the set of glyphs it draws with. Eight themes are built in, and you can write your own in a few lines by extending one of them.
Pick a theme
$ unifi theme get
NAME SOURCE DESCRIPTION
catppuccin built-in Soothing pastels, Catppuccin Mocha on dark and Latte on light terminals
dracula built-in Dracula's vivid night colors, with the Alucard palette on light terminals
gruvbox built-in Retro groove with warm, earthy contrast
mono built-in Greyscale for minimalists, state is told apart by lightness alone
nord built-in Arctic, north-bluish calm, Polar Night on dark and Snow Storm on light terminals
solarized built-in Precision colors for machines and people, Solarized Dark and Light
tokyo-night built-in The lights of downtown Tokyo at night, Tokyo Night Day on light terminals
● unifi built-in The default theme, modeled on the UniFi Network consoleSee them before you choose:
unifi theme preview nord # one theme on real components, dark and light side by side
unifi theme preview --all # every theme as a compact cardunifi theme preview --all, followed by the full previews of nord and tokyo-night with their dark and light variants side by side.
Then select one:
unifi theme use nord
unifi theme use # pick from a list, on a terminalunifi theme use loads the theme for both color schemes before it saves the preference, so a theme file with a mistake is reported instead of selected.
For a single command, --theme overrides the configured theme:
unifi dashboard --theme tokyo-nightIn the dashboard, t cycles through the themes and c toggles dark and light, which is the fastest way to find one that suits your terminal.
Dark and light
Every theme carries two sets of colors. With colorScheme: auto, the default, unifi-cli asks the terminal for its background color and picks the matching set.
The question gets 100 milliseconds, and the answer is remembered per terminal for a day, so it costs nothing on the next command. Live views ask again while they run and follow the terminal when it switches between light and dark.
Some terminals and most multiplexers don't answer that question, and then the guess can be wrong. Pin the scheme when that happens:
unifi config set colorScheme dark # for good
unifi clients get --color-scheme light # for one commandOutput that goes to a pipe or a file has no colors at all, so unifi clients get | grep NAS gives you plain text.
Write your own theme
Scaffold a theme that extends a built-in one:
$ unifi theme create homelab --extends nord
✓ Created the theme "homelab" in ~/.config/unifi-cli/themes/homelab.yaml.
→ Edit the file: every token is listed with the value it inherits.
→ See it with `unifi theme preview homelab`.
→ Select it with `unifi theme use homelab`.The file works right away, because everything it leaves out comes from the theme it extends. It lists every token as a comment with the inherited value, ready to be uncommented and changed.
unifi theme edit homelab # opens the file in $VISUAL or $EDITOR and checks it when the editor closes
unifi theme delete homelab # asks first; built-in themes can't be deletededit works on a copy. A file that doesn't parse, or whose dark or light variant has a mistake, is reported and the theme stays as it was. Deleting the theme that is in use puts unifi-cli back on the default theme.
A finished theme can be short. This one is examples/themes/homelab.yaml from the repository:
# yaml-language-server: $schema=https://unifi-cli.specht-labs.de/schema/theme.schema.json
apiVersion: unifi.specht-labs.de/v1alpha1
kind: Theme
name: homelab
description: Nord with an orange accent and square borders
extends: nord
border: square
palette:
rack-orange: "#D08770"
rack-orange-dark: "#B5613F"
dark:
primary: p:rack-orange
warning: p:nord13
danger: p:nord11
light:
primary: p:rack-orange-darkHow the pieces fit
extends names the theme to inherit from, built-in or your own. Chains are allowed, up to eight levels deep.
palette gives names to colors, written as #RRGGBB. A token then refers to a palette entry as p:<name>. The palette of the extended theme is inherited, which is why the example can use p:nord13 without defining it.
dark and light map the semantic tokens for each color scheme. There are twelve color tokens (background, surface, border, text, muted, subtle, primary, secondary, success, warning, danger, info) and series, a list of colors for chart series. A token takes a #RRGGBB color or a palette reference; named colors and 3-digit hex aren't accepted.
border is one of rounded, square, thick, double or ascii.
glyphs is unicode or ascii.
The theme reference describes what each token colors.
Where themes live
unifi theme pathEvery <name>.yaml in that directory, ~/.config/unifi-cli/themes by default, is a theme. A file named like a built-in theme replaces it, so nord.yaml in your themes directory is your own nord.
To start from a complete file instead of a scaffold, dump a theme with everything it inherits merged in:
unifi theme get nord > "$(unifi theme path)/my-nord.yaml"Change the name in the copy, or leave it out; the file name is the theme's name.
Editor support
Scaffolded files start with a schema reference, and editors with a YAML language server complete and validate token names from it. A misspelled token is also an error when the theme loads, because unknown fields are rejected:
$ unifi theme use homelab
✗ The theme file could not be parsed.
Theme "homelab" is not a valid theme file.
Advice:
• Fix the file, or switch themes with `unifi theme use unifi`.
• Check the file against the theme schema: `unifi config schema theme`.
• Compare it with a built-in theme: `unifi theme get unifi --output yaml`.
Caused by:
→ yaml: construct errors: line 11: field bogusKey not found in type theme.DefinitionGlyph sets
The unicode glyph set uses box-drawing characters, block elements and braille dots for graphs. Most terminal fonts have them. If yours doesn't, or you're on a serial console, switch to the ascii set:
$ unifi config set glyphs ascii
✓ Set glyphs to "ascii".
$ unifi ports get "Garage Switch"
+- Garage Switch ------------------- 4/8 up | PoE 4.4 W -+
| 1 2 3 4 5 6 7 8 |
| . -p . . - - x +^ |
| |
| + 1 GbE - 100 FE . down x disabled p PoE ^ uplink |
+--------------------------------------------------------+The glyphs preference overrides whatever the theme says, and it switches the borders along with the symbols, so every view, the dashboard and the topology diagram included, is drawn with 7-bit characters only. unifi config set glyphs "" clears the override.
