Skip to main content

Overview

Glow uses Glamour for markdown rendering, which supports custom styles defined in JSON format. Custom styles allow you to completely control how markdown is rendered in your terminal.

Built-in Styles

Before creating custom styles, you may want to try Glow’s built-in styles:
  • auto - Automatically adapts to your terminal’s background (dark or light)
  • dark - Optimized for dark terminals
  • light - Optimized for light terminals
  • pink - Pink color scheme
  • dracula - Dracula theme
  • tokyonight - Tokyo Night theme
  • notty - Plain text output for non-TTY environments
# Try different built-in styles
glow --style dark README.md
glow --style dracula README.md
glow --style pink README.md

Using Custom Styles

Via Command Line

Specify a path to your custom JSON style file:
glow --style ~/.config/glow/styles/custom.json README.md

Via Configuration File

Set the style path in your glow.yml:
style: "~/.config/glow/styles/custom.json"
width: 100
Paths starting with ~ are automatically expanded to your home directory, and environment variables are resolved.

Via Environment Variable

Use the GLAMOUR_STYLE environment variable:
export GLAMOUR_STYLE="~/.config/glow/styles/custom.json"
glow README.md

Style File Structure

Glamour styles are defined as JSON files following the ansi.StyleConfig schema. Here’s the basic structure:
{
  "document": {
    "color": "#FAFAFA",
    "margin": 2
  },
  "heading": {
    "color": "#E88388",
    "bold": true
  },
  "h1": {
    "color": "#F1FA8C",
    "bold": true,
    "prefix": "\n# "
  },
  "code_block": {
    "color": "#8BE9FD",
    "margin": 2
  }
}

Style Properties

Each element in your style can have these properties:

Color Properties

PropertyTypeDescription
colorStringForeground color (hex or ANSI)
background_colorStringBackground color (hex or ANSI)

Text Formatting

PropertyTypeDescription
boldBooleanBold text
italicBooleanItalic text
underlineBooleanUnderlined text
strikethroughBooleanStrikethrough text
faintBooleanDim/faint text

Layout Properties

PropertyTypeDescription
marginIntegerMargin (in lines)
indentIntegerIndentation (in spaces)
prefixStringText prefix
suffixStringText suffix

Styleable Elements

You can customize these markdown elements:

Document Structure

  • document - Root document styles
  • block_quote - Blockquote text
  • paragraph - Regular paragraphs

Headings

  • heading - All headings (inherited by h1-h6)
  • h1, h2, h3, h4, h5, h6 - Individual heading levels

Text Styles

  • text - Regular text
  • strong - Bold text (bold)
  • emph - Italic text (italic)
  • strikethrough - Strikethrough (text)

Code

  • code - Inline code
  • code_block - Code blocks

Lists

  • list - All lists
  • enumeration - Ordered lists
  • item - List items
  • link - Link text
  • link_text - Link label
  • image - Image elements
  • image_text - Image alt text

Tables

  • table - Table container
  • table_row - Table rows
  • table_cell - Table cells
  • table_header - Table headers

Other Elements

  • hr - Horizontal rule
  • html_block - HTML blocks
  • html_span - Inline HTML

Example Custom Styles

Minimalist Style

{
  "document": {
    "color": "#E0E0E0",
    "margin": 1
  },
  "heading": {
    "bold": true
  },
  "h1": {
    "color": "#FFFFFF",
    "prefix": "\n",
    "suffix": "\n"
  },
  "h2": {
    "color": "#F0F0F0",
    "prefix": "\n"
  },
  "code": {
    "color": "#A8A8A8",
    "background_color": "#2A2A2A"
  },
  "code_block": {
    "color": "#C0C0C0",
    "background_color": "#1A1A1A",
    "margin": 1
  },
  "link": {
    "color": "#8888FF",
    "underline": true
  }
}

High Contrast Style

{
  "document": {
    "color": "#FFFFFF"
  },
  "h1": {
    "color": "#FFFF00",
    "bold": true,
    "background_color": "#000080",
    "prefix": " ",
    "suffix": " "
  },
  "h2": {
    "color": "#00FFFF",
    "bold": true
  },
  "strong": {
    "color": "#FF0000",
    "bold": true
  },
  "code": {
    "color": "#00FF00",
    "background_color": "#000000"
  },
  "link": {
    "color": "#FF00FF",
    "bold": true
  }
}

Solarized Dark Style

{
  "document": {
    "color": "#839496",
    "margin": 2
  },
  "h1": {
    "color": "#268BD2",
    "bold": true
  },
  "h2": {
    "color": "#2AA198",
    "bold": true
  },
  "code": {
    "color": "#93A1A1",
    "background_color": "#073642"
  },
  "code_block": {
    "color": "#93A1A1",
    "background_color": "#002B36",
    "margin": 2
  },
  "emph": {
    "color": "#B58900",
    "italic": true
  },
  "strong": {
    "color": "#CB4B16",
    "bold": true
  },
  "link": {
    "color": "#6C71C4",
    "underline": true
  }
}

Style File Locations

~/.config/glow/
├── glow.yml
└── styles/
    ├── custom.json
    ├── work.json
    └── presentation.json

Platform-Specific Paths

~/.config/glow/styles/

Testing Custom Styles

Quick Test

Test your style without modifying your config:
glow --style path/to/style.json README.md

Create a Test Document

Create a markdown file with various elements to test:
test.md
# Heading 1
## Heading 2
### Heading 3

Regular paragraph with **bold** and *italic* text.

`inline code` and code blocks:

```bash
echo "Hello, World!"
  • List item 1
  • List item 2
    • Nested item
  1. Ordered item
  2. Another item
Blockquote text
Link text
Table:
Column 1Column 2
Data 1Data 2

Then test:

```bash
glow --style your-style.json test.md

Auto Style Behavior

When using style: "auto", Glow automatically selects the appropriate style:
utils/utils.go
case styles.AutoStyle:
    if lipgloss.HasDarkBackground() {
        styleConfig = styles.DarkStyleConfig
    } else {
        styleConfig = styles.LightStyleConfig
    }
This detection happens at runtime based on your terminal’s background color.

Glamour Documentation

For complete documentation on Glamour styles, including advanced features and the full schema:

Glamour Styles

Official Glamour style reference with complete examples and schema documentation

Troubleshooting

Style Not Loading

  1. Verify the JSON syntax is valid:
    python -m json.tool < your-style.json
    
  2. Check the file path is correct and accessible
  3. Use an absolute path if relative paths aren’t working:
    glow --style /full/path/to/style.json README.md
    

Colors Not Displaying

  • Ensure your terminal supports 24-bit color (true color)
  • Try using ANSI color codes instead of hex values
  • Check your $TERM environment variable

Style Validation

Glow validates the style file on load. If there’s an error:
glow --style broken-style.json README.md
# Error: specified style does not exist: broken-style.json
Common issues:
  • File doesn’t exist
  • Invalid JSON syntax
  • Incorrect file permissions

Tips and Best Practices

  1. Start with a built-in style - Copy and modify an existing Glamour style
  2. Test incrementally - Make small changes and test frequently
  3. Use semantic colors - Keep related elements visually similar
  4. Consider accessibility - Ensure sufficient contrast
  5. Document your style - Add comments in a separate README file
  6. Version control - Keep your styles in a git repository

Build docs developers (and LLMs) love