# Themes
`deft/stdext/theme` provides Deft-side access to the active workspace
theme plus a reactive rebuild helper, and `src/themes/` ships the
built-in theme files.
import "deft/stdext/theme" as theme
## API
| Def | Signature | Description |
|---|---|---|
| `_get` | `{||}` | The full active theme map, cached until its `name\|fg\|bg\|accent` signature changes |
| `on-change` | `{| theme rebuild-fn |}` | Call once from `Panel.draw`; invokes the zero-arg callback when the tracked colors change |
`_get` reads `[theme/current]`, falling back to `[tui/theme]` (headless
safe; nil if neither). The map is the same full map as
`[theme/current]` / `[draw/theme ctx]`: all sections of the active theme
file plus per-package `theme.dft` fragments merged under their app key.
set t [theme/_get] echo $t~markdown~heading-fg
defimpl MyApp Panel { draw {| ctx | [theme/on-change [draw/theme $ctx] rebuild-widget-tree] # …rest of draw… } }
## Theme Files
A theme is a single Deft map:
%{
:name "Dracula"
:ui %{ :bg "#282a36" :fg "#f8f8f2" :accent "#bd93f9" }
:syntax %{ :keyword "#ff79c6" :string "#f1fa8c" }
:help %{ :heading-fg "#8be9fd" }
:markdown %{ :heading-fg "#bd93f9" :code-bg "#21222c" }
:log %{ :ok "#50fa7b" :debug "#6272a4" :info "#8be9fd"
:warn "#f1fa8c" :error "#ff5555" }
}
- Keys are keywords; values are color strings. Extra sections flow to
Deft consumers generically.
- `:log` is the severity palette for log-style apps and the workspace
badge dots set with `[tui/badge :error]` / `:warn` / ….
- Omitted standard sections yield nil, so apps keep their fallbacks.
- `theme/save` canonicalizes on write (`# <name>` header, sections in
`name → ui → syntax → help → markdown → extras` order, sorted keys,
atomic rename), so files stay diff-stable.
### Shipped Themes
| File | `:name` |
|---|---|
| `catppuccin-mocha.dft` | Catppuccin Mocha |
| `dracula.dft` | Dracula |
| `gruvbox-dark.dft` | Gruvbox Dark |
| `nord.dft` | Nord |
| `solarized-dark.dft` | Solarized Dark |
Search order (first hit per display name wins): `.deft/local/themes/` →
prelude `:themes :dir` → `<home>/local/themes/` → the stdext `themes/`
mount → legacy `./themes/`. Shipped files are never modified; edits
shadow into the project's local themes dir.
## See Also
- Themes (manual) — `theme/load`, `theme/set`, the canonical format
- Graphics — color forms and `draw/*`
- Widgets and Protocols — theme-aware color fallback