package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou-core.style/Miaou_style/Theme/index.html
Module Miaou_style.ThemeSource
Theme definition with semantic styles and CSS-like widget styling rules.
A theme consists of:
- Semantic styles (primary, error, text, etc.) for consistent appearance
- Widget rules using CSS-like selectors for targeted styling
Example theme JSON:
{
"name": "dark",
"primary": { "fg": 75, "bold": true },
"error": { "fg": 196 },
"text": { "fg": 252 },
"border": { "fg": 240 },
"rules": {
"table:focus": { "style": { "border_fg": 75 } },
"flex_layout > :nth-child(even)": { "style": { "bg": 236 } },
"modal .button": { "style": { "fg": 255, "bold": true } }
}
}type widget_style = {style : Style.t;(*Base style (colors, text attributes)
*)border_style : Border.style option;(*Optional border style override
*)border_fg : Style.color option;(*Optional border foreground color
*)border_bg : Style.color option;(*Optional border background color
*)
}Widget style with optional border configuration
JSON encoding/decoding for widget styles (tolerant of missing fields).
A style rule: selector -> widget style
type t = {name : string;(*Theme name (e.g., "dark", "light")
*)dark_mode : bool;(*Whether this is a dark theme (affects color resolution for Adaptive colors)
*)primary : Style.t;(*Primary accent color
*)secondary : Style.t;(*Secondary color
*)accent : Style.t;(*Accent/highlight color
*)error : Style.t;(*Error/danger
*)warning : Style.t;(*Warning
*)success : Style.t;(*Success/positive
*)info : Style.t;(*Information
*)text : Style.t;(*Normal text
*)text_muted : Style.t;(*Muted/secondary text
*)text_emphasized : Style.t;(*Emphasized text
*)background : Style.t;(*Main background
*)background_secondary : Style.t;(*Secondary/panel background
*)border : Style.t;(*Default border
*)border_focused : Style.t;(*Focused border
*)border_dim : Style.t;(*Dimmed border
*)selection : Style.t;(*Selected item
*)default_border_style : Border.style;rules : rule list;
}Theme definition
Default theme
Empty widget style (inherits everything)
Style resolution
Find all rules matching a context, ordered by specificity (most specific last)
Resolve the complete style for a widget context. Merges semantic styles with matching rules, respecting specificity.
Get semantic style by name (e.g., "primary", "error", "text")
Validation
Validate theme styles for low-contrast fg/bg combinations. Returns a list of human-readable warnings.
Theme merging
Merge two themes. Values from overlay take precedence when set.
JSON serialization
Convert theme to JSON
Parse theme from JSON