Chapter 79

The Application Theme format

An Application Theme styles Pilcrow itself: its light or dark appearance, the accent colour, the sidebar, the status and formatting bars, and the editor. It is a JSON file. Rendered documents (Preview, HTML, PDF, image, print and Word) are styled separately by a Render Theme, which is CSS (Chapter 80). The two kinds are installed, chosen and deleted separately, and neither follows the other.

A complete example#

{
  "pilcrowAppTheme": 1,
  "name": "Nord",
  "appearance": "dark",
  "colors": {
    "accent": "#88C0D0",
    "sidebar": { "background": "#2E3440", "foreground": "#D8DEE9" },
    "bars": { "background": "#3B4252", "foreground": "#D8DEE9" },
    "editor": {
      "background": "#2E3440",
      "foreground": "#ECEFF4",
      "cursor": "#88C0D0",
      "selection": "#434C5E",
      "gutterBackground": "#2E3440",
      "gutterForeground": "#4C566A"
    },
    "syntax": {
      "heading": "#88C0D0",
      "marker": "#EBCB8B",
      "code": "#A3BE8C",
      "link": "#81A1C1",
      "muted": "#7B88A1",
      "tokens": { "strong": "#D08770" }
    }
  }
}

Top level#

KeyRequiredValue
pilcrowAppThemeyesThe format version, 1.
nameyes1–200 characters. Shown in Settings and the Themes menu.
appearanceyes"light", "dark" or "automatic".
colorslight and dark themesOne palette (below).
light, darkautomatic themesTwo palettes: one used in the system's light appearance, one in dark.
idnoWritten by Pilcrow for its own library. Ignored on import, which always assigns a new id.

appearance decides the appearance of every window: menus, Settings, sheets and pickers included. A light or dark theme fixes it; automatic follows the system.

An automatic theme must set each colour in both light and dark or in neither. A colour set for one appearance only would otherwise be drawn in the other.

Palette#

Every key is optional. A colour left out keeps Pilcrow's built-in look, so a theme can be as small as one accent colour.

KeyStyles
accentThe app-wide tint: buttons, selected segments, toggles, links, focus rings, and the sidebar's selected row. Unset keeps the system accent.
sidebar.background, sidebar.foregroundThe Files, Outline and Find sidebar. Secondary labels derive from the foreground.
bars.background, bars.foregroundThe status bar, the docked formatting toolbar, and import notices. Secondary labels derive from the foreground.
editor.background, editor.foregroundThe editor canvas and body text.
editor.cursor, editor.selectionThe insertion point and the selection highlight.
editor.gutterBackground, editor.gutterForegroundThe line-number gutter. The background defaults to the editor background.
editor.currentLineRuleThe thin rule under the line the caret is on, when View ▸ Current-Line Rule is on. Defaults to the editor text colour at low strength.
syntax.<group>Live syntax colours by group (below).
syntax.tokens.<raw>One token by its raw value, overriding its group.

Syntax groups#

GroupColours
headingHeadings (markers and text), alert markers, definition terms
markerEmphasis, strong, strikethrough and other inline delimiters; list and task markers
codeInline code, fenced and indented code blocks, math, HTML blocks
linkLink and image labels and destinations, autolinks
mutedBlock quote markers, thematic breaks, table rows, comments, block attributes
codeKeyword, codeString, codeNumber, codeCommentHighlighted code inside a fence

A group left unset takes a built-in colour chosen for the editor background: darker tones on a light canvas, lighter tones on a dark one. Token names in syntax.tokens use letters, digits, _ and -, and cannot repeat a group name (syntax.heading already covers heading).

Colours#

Every colour is a hex string: #RGB, #RGBA, #RRGGBB or #RRGGBBAA, in sRGB. Pilcrow stores them in upper case.

Validation#

Pilcrow refuses a file rather than ignore part of it, and names the key at fault, for example colors.editor.cursor: must be a hex colour. It refuses:

  • a missing or different pilcrowAppTheme version;
  • an unknown key at any level (usually a typo);
  • a palette key that does not match the appearance (colors in an automatic theme, light and dark in a light or dark one);
  • a colour that is not hex;
  • an automatic theme whose light and dark palettes set different colours.

What an Application Theme does not change#

The window title bar and toolbar (the system's glass, which takes only the accent), menus, Settings, sheets and pickers keep their native look apart from appearance and accent. Fonts are not themed: the editor font and size are set in Settings ▸ Appearance ▸ Text Size & Fonts.

Installing and sharing#

  • Import a .json file from Settings ▸ Library ▸ Themes, File ▸ Import ▸ Theme on the Mac, or Settings ▸ Library ▸ Import on iPad. Dropping the file on Pilcrow works too.
  • A .zip theme package may hold Application Themes beside Render Themes (Chapter 80).
  • The share button beside a theme saves its .json file, or the whole package when the theme came from one.

Pilcrow includes three Application Themes: Automatic, Light and Dark. They set the editor and syntax colours and leave the chrome at its built-in look.