Lets the user choose a named palette: a menu in the top bar or a grid of previews on a settings page. Each option previews its own colors.
<.theme_picker id="palette" />
<.theme_picker id="palette" variant="grid" />
<.theme_picker id="palette" themes={~w(ledger noite)} label="Tema" />The palette is apart from the mode: theme_switch/1 picks light, dark or system, the picker
picks which palette. The LedgerUI.ThemePicker hook puts the choice on
<html data-palette>, keeps it in localStorage["ledger-palette"], marks the option and tells every
picker through the ledger:palette window event. on_change also pushes %{"theme" => id} to
the LiveView. Put <.theme_script theme="..." /> in the root layout so the stored palette is on
before the first paint.
ledger.css ships two palettes, ledger (default) and crepusculo (<html data-palette="crepusculo">:
indigo brand, Inter Tight headings, its own hero and auth art); themes/0 lists them first-class next to
the sample previews. Pass themes={~w(ledger crepusculo)} for the real ones.
themes takes ids of the built-in list (themes/0) or maps %{id, label} (optionally bg,
accent, ink for the preview).
Summary
Functions
Attributes
id(:string) (required)variant(:string) - Defaults to"menu". Must be one of"menu", or"grid".themes(:list) - Ids or%{id, label}maps; defaultthemes/0. Defaults tonil.default(:string) - The theme shown when nothing is stored. Defaults tonil.current(:string) - The same asdefault. Defaults tonil.label(:string) - Defaults to"Theme".placement(:string) - Defaults to"bottom-end". Must be one of"bottom-end", or"bottom-start".on_change(:string) - Defaults tonil.target(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
The built-in themes.