Introducing a new way to review your PRs.

Read the announcement

arhamkhnz / next-shadcn-admin-dashboard

Modern Admin Dashboard Template built with Shadcn UI and Next.js 16

View on GitHub

22 documents · Updated Nov 23, 2026

docs / personalization-system

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 groupUser choiceDashboard effect
ThemeLight, dark, or system modeSelects the resolved color mode.
Theme presetDefault, Brutalist, Soft Pop, or TangerineSelects the visual color and shape treatment.
FontA registered font choiceChanges the main type face.
Page layoutCentered or full widthSets the width of the shared content area.
Navbar behaviorSticky or scrollControls how the dashboard header behaves during page scroll.
Sidebar styleSidebar, inset, or floatingSets the visual form of dashboard navigation.
Sidebar collapse modeIcon or offcanvasSets 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

TriggerConsequenceGuard
A saved value is no longer in the allowed preference setThe boot step falls back while another layer may still expect the old choiceKeep parsing, controls, and consumers tied to the same preference definitions.
A layout-critical value differs between the server shell and the document at first paintThe dashboard can change shape during hydration or show a layout flickerPreserve cookie-backed loading and early document application for sidebar layout choices.
System theme subscription is not replaced when the user selects light or darkBrowser color changes can continue to alter a mode the user selected directlyStart and stop the system listener with the selected theme mode.
A new document attribute has no matching CSS or shell consumerThe control appears to work but has no visible effectTrace the preference from its registry entry through runtime application to its final consumer.

Key files

FileWhy to read it
src/…/preferences-config.tsDefines the preference contract, allowed values, defaults, and persistence modes.
src/…/preferences-store.tsShows how live changes and restore-default actions update state and save values.
src/…/preferences-provider.tsxConnects the client store to document state and system theme changes.
src/…/theme-boot.tsxShows how saved preferences affect the document before hydration.
src/…/layout-controls.tsxShows the complete user-facing preference surface.
src/…/layout.tsxShows where shared preferences shape the dashboard frame.
src/…/globals.cssShows how document attributes and the dark class become visual styles.