theme

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package theme loads and resolves built-in and custom UI themes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBuiltin

func IsBuiltin(name string) bool

IsBuiltin returns true for the built-in theme names.

func ListAvailable

func ListAvailable() []string

ListAvailable returns all theme names: built-ins first, then embedded themes, then any additional JSON files found in the user config themes directory. User config themes that share a name with an embedded theme are not duplicated (the load path already prefers the user config file for overrides).

Types

type CodeBlockStyle

type CodeBlockStyle struct {
	ElementStyle
	Theme string `json:"theme,omitempty"`
}

CodeBlockStyle extends ElementStyle with a chroma syntax-highlight theme name.

type CustomTheme

type CustomTheme struct {
	// Markdown controls markdown rendering (headings, code blocks, etc).
	Markdown MarkdownStyle `json:"markdown,omitempty"`

	// BaseTheme, if set to "light" or "dark", determines which built-in theme
	// supplies default values for any fields not specified in the custom theme.
	BaseTheme *string `json:"base_theme"`

	// Fern-specific UI colors (lipgloss).
	Accent       *string `json:"accent"`
	Dim          *string `json:"dim"`
	Text         *string `json:"text"`
	TabBg        *string `json:"tab_bg"`
	CursorGutter *string `json:"cursor_gutter"`
	Help         *string `json:"help"`
	SelectedBg   *string `json:"selected_bg"`

	ModeView    *string `json:"mode_view"`
	ModeNormal  *string `json:"mode_normal"`
	ModeInsert  *string `json:"mode_insert"`
	ModeReplace *string `json:"mode_replace"`
	ModeVisual  *string `json:"mode_visual"`

	Error   *string `json:"error"`
	Warn    *string `json:"warn"`
	Success *string `json:"success"`
	Info    *string `json:"info"`
	Tag     *string `json:"tag"`
}

CustomTheme holds a MarkdownStyle for markdown rendering alongside fern-specific UI color overrides for lipgloss styles. For built-in themes both are set explicitly. For custom themes a JSON theme file is loaded and UI colors are derived from the heading colors.

func Resolve

func Resolve(themeName string) CustomTheme

Resolve returns a fully-populated CustomTheme for the given name. Built-in themes return their predefined palettes. Custom themes load a JSON file and derive UI colors from it.

type ElementStyle

type ElementStyle struct {
	Color *string `json:"color,omitempty"`
}

ElementStyle holds color styling for a markdown element.

type MarkdownStyle

type MarkdownStyle struct {
	H1        ElementStyle   `json:"h1,omitempty"`
	H2        ElementStyle   `json:"h2,omitempty"`
	H3        ElementStyle   `json:"h3,omitempty"`
	H4        ElementStyle   `json:"h4,omitempty"`
	H5        ElementStyle   `json:"h5,omitempty"`
	H6        ElementStyle   `json:"h6,omitempty"`
	Heading   ElementStyle   `json:"heading,omitempty"`
	Text      ElementStyle   `json:"text,omitempty"`
	Link      ElementStyle   `json:"link,omitempty"`
	Item      ElementStyle   `json:"item,omitempty"`
	CodeBlock CodeBlockStyle `json:"code_block,omitempty"`
}

MarkdownStyle defines markdown rendering appearance. These fields map directly to JSON keys in a custom theme file under "markdown".

func (MarkdownStyle) ToAnsiStyleConfig

func (ms MarkdownStyle) ToAnsiStyleConfig(baseName string) ansi.StyleConfig

ToAnsiStyleConfig converts to an ansi.StyleConfig for glamour, starting from the named built-in base (light or dark) and overlaying any non-nil fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL