Personalization system
The personalization system lets each dashboard user shape the visual form of the application without changing page content or meaning. It joins theme and layout choices into one preference flow that starts with saved browser state and ends as document and dashboard-shell behavior.
Personalization boundary
The system has one shared preference boundary at the application root. The root document receives the current choices, while the dashboard shell uses those choices to build a matching navigation and content frame. This keeps display choices consistent as a user moves between dashboard destinations. src/…/layout.tsx, src/…/layout.tsx
The preference surface is intentionally separate from feature data. A page can change its own content or use a full-bleed view, but the shared system remains responsible for the user's general visual settings. The dashboard exposes these settings from its header through a preference panel and a quick theme control. src/…/layout-controls.tsx, src/…/theme-switcher.tsx
Preference model
The preference model defines the allowed values and the default for every supported display choice. Invalid or missing values resolve to the default, so saved browser state cannot introduce an unknown dashboard mode. src/…/preferences-config.ts
| Preference group | User choice | Dashboard effect |
|---|---|---|
| Theme | Light, dark, or system mode | Selects the resolved color mode. |
| Theme preset | Default, Brutalist, Soft Pop, or Tangerine | Selects the visual color and shape treatment. |
| Font | A registered font choice | Changes the main type face. |
| Page layout | Centered or full width | Sets the width of the shared content area. |
| Navbar behavior | Sticky or scroll | Controls how the dashboard header behaves during page scroll. |
| Sidebar style | Sidebar, inset, or floating | Sets the visual form of dashboard navigation. |
| Sidebar collapse mode | Icon or offcanvas | Sets how the sidebar behaves when collapsed. |
Theme choices
Theme mode describes the user's intent, while resolved theme mode describes the light or dark result used by the page. In system mode, the result follows the browser's color-scheme setting and can change while the dashboard is open. Theme presets provide a separate visual layer, so a color preset and a light or dark mode can work together.
References: src/…/theme.ts• L1-50 src/…/theme-utils.ts• L3-38 src/…/globals.css• L55-128
Layout choices
Layout preferences shape the shared dashboard frame rather than the data shown inside a page. Content width and header behavior are applied through the document, while sidebar style and collapse mode are consumed by the dashboard shell so navigation stays aligned with the selected frame.
References: src/…/layout.ts• L1-32 src/…/layout.tsx• L21-51
Preference controls
The dashboard header gives users two ways to change appearance. The preference panel groups the full set of theme and layout choices and can restore all defaults, while the theme button cycles through light, dark, and system modes for a fast change. Both controls update the same preference state instead of maintaining separate UI settings.
References: src/…/layout-controls.tsx• L16-68 src/…/layout-controls.tsx• L70-229 src/…/theme-switcher.tsx• L9-36
Preference lifecycle
The lifecycle connects saved values to the first page paint and then to live client state. The boot step applies valid saved values before hydration, and the provider then reads the document state so interactive controls and the rendered document start from the same view.
This diagram shows how a dashboard preference moves from a saved value to the document and the dashboard shell.
flowchart LR
Saved[Saved browser preference] --> Boot[Early theme and layout boot]
Defaults[Defined defaults] --> Boot
Boot --> Document[Document attributes and theme class]
Document --> Provider[Client preference state]
Provider --> Controls[Dashboard preference controls]
Provider --> Shell[Dashboard shell]
Controls --> Update[Preference change]
Update --> Document
Update --> Saved
Initial preference application
The root layout places default attributes on the document and runs the boot step before hydration. The boot step reads saved values, rejects values outside the preference model, and applies the selected attributes and color mode early. This reduces a visible switch between the saved dashboard view and the first interactive view.
References: src/…/layout.tsx• L21-43 src/…/theme-boot.tsx• L10-77
Live preference updates
After the page starts, the client store is the shared source for user changes. A change updates the document immediately and then saves the value through its configured storage path. Reset follows the same route for every preference, which returns both the document and the in-memory state to the defined defaults.
References: src/…/preferences-store.ts• L21-61 src/…/preference-runtime.ts• L7-17
System theme response
System mode has a live relationship with the browser rather than one fixed color result. When the user selects system, the provider listens for browser color-scheme changes and refreshes the resolved mode; selecting light or dark removes that listener.
References: src/…/preferences-provider.tsx• L48-82 src/…/theme-utils.ts• L24-38
Dashboard integration
The dashboard shell consumes the preference boundary at the points where a choice changes structure or appearance. The content area reads the document's layout state. The header reads its navigation behavior. The sidebar receives the selected style and collapse mode. This lets all dashboard pages share one preference model while still allowing a page to opt into a full-bleed content area when needed. src/…/layout.tsx
The deeper state, persistence, layout, and theme runtime behavior is documented in Preferences and theme runtime.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep each preference's allowed values, default, document attribute, boot behavior, and CSS or shell consumer aligned.
- When a layout-critical preference changes, preserve agreement between the server-rendered dashboard shell and the browser's first state.
- When adding a new dashboard control, connect it to the shared preference store instead of creating local display state.
- When changing system theme behavior, check both the early boot result and live browser color-scheme changes.
- When changing a theme preset, keep its selectable value, generated theme data, and light and dark CSS treatment in step.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A saved value is no longer in the allowed preference set | The boot step falls back while another layer may still expect the old choice | Keep parsing, controls, and consumers tied to the same preference definitions. |
| A layout-critical value differs between the server shell and the document at first paint | The dashboard can change shape during hydration or show a layout flicker | Preserve cookie-backed loading and early document application for sidebar layout choices. |
| System theme subscription is not replaced when the user selects light or dark | Browser color changes can continue to alter a mode the user selected directly | Start and stop the system listener with the selected theme mode. |
| A new document attribute has no matching CSS or shell consumer | The control appears to work but has no visible effect | Trace the preference from its registry entry through runtime application to its final consumer. |
Key files
| File | Why to read it |
|---|---|
| src/…/preferences-config.ts | Defines the preference contract, allowed values, defaults, and persistence modes. |
| src/…/preferences-store.ts | Shows how live changes and restore-default actions update state and save values. |
| src/…/preferences-provider.tsx | Connects the client store to document state and system theme changes. |
| src/…/theme-boot.tsx | Shows how saved preferences affect the document before hydration. |
| src/…/layout-controls.tsx | Shows the complete user-facing preference surface. |
| src/…/layout.tsx | Shows where shared preferences shape the dashboard frame. |
| src/…/globals.css | Shows how document attributes and the dark class become visual styles. |