Skip to content

useSettings

useSettings() exposes the active theme’s customizable schema plus the current overrides, with set / reset operations. The Settings system window uses it; consumers building their own settings UI use the same surface.

import { useSettings } from "@react-ui-os/desktop";
PropertyTypeDescription
schemaRecord<string, CustomizableField>The active theme’s customizable map. Empty {} when the theme exposes none.
prefsRecord<string, unknown>Current user overrides keyed by the same dotted paths. {} when nothing has been set.
setPref(path: string, value: unknown) => voidWrite a single override. Triggers immediate re-render of the desktop.
resetPref(path: string) => voidRemove one override, falling back to the theme default.
resetAll() => voidClear every override for the active theme.
function AccentChip({ hex }: { hex: string }) {
const { setPref } = useSettings();
return (
<button
onClick={() => setPref("palette.accent", hex)}
style={{ background: hex }}
/>
);
}
const { schema } = useSettings();
const supportsLeftDock = "chrome.dockPosition" in schema;
function ResetMenu() {
const { resetAll, prefs } = useSettings();
const hasOverrides = Object.keys(prefs).length > 0;
return hasOverrides ? <button onClick={resetAll}>Reset all settings</button> : null;
}

setPref writes synchronously through the active StorageAdapter under the key settings:<themeId>. The change event fires, the desktop context re-reads, the effective theme rebuilds, every useTheme() consumer re-renders. No polling.