# theme/save Write a theme map back to disk as a canonical theme `.dft` file. ## Syntax
[theme/save $t]
[theme/save $t "themes/my-copy.dft"]
## Parameters - `theme` — a theme map (from `theme/load` or a modified copy). - `?path` — (optional) explicit output path; wins over all location rules. ## Write-target rules With no explicit path, `theme/save` resolves the target from the provenance `theme/load` recorded: 1. Writable origin — a theme loaded from a user dir (project `.deft/local/themes`, user home, a prelude `:themes :dir`, or legacy `./themes`) is overwritten in place. 2. Shipped default — a theme loaded from the stdext mount gets an override shadow written to `<project .deft>/local/themes/` <stem>.dft`; the shipped file is never modified.` 3. Unloaded map — a map constructed in Deft (never loaded from disk) saves to the shadow dir with a stem slugified from its `:name` (`"Catppuccin Mocha"` → `catppuccin-mocha.dft`); an error when `:name` is missing. ## File format Files are written canonically so they round-trip diff-stable: 4-space indented nested maps, sections ordered `name → ui → syntax → help → markdown` then extras, keys sorted alphabetically within every map, a `# <name>` header comment, and an atomic write-then-rename. ## Examples
set t [theme/load :dracula]
set t [theme/set $t :ui :accent "#ffffff"]
[theme/save $t]                # → ".deft/local/themes/dracula.dft" (shadow)
[tui/theme-reload]             # pick the change up in a running TUI
## Returns The written path as a string, or `nil` on failure. ## See Also `theme/load`, `theme/set`, `theme/unset`, `theme/list`, `tui/theme-reload`, `tui/set-theme`