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 / ui-foundation

UI foundation

The UI foundation is the shared presentation layer for application and dashboard experiences. It supplies a common visual language, reusable interaction surfaces, and display helpers so feature pages can focus on their work flow instead of rebuilding basic controls.

Foundation role

The foundation joins visual tokens, reusable React components, and focused display helpers into one layer. Pages compose these parts to present content, collect input, show state, and support navigation across screen sizes.

Shared visual language

The global style contract defines the colors, borders, focus rings, radii, chart colors, sidebar colors, and font roles that shared components use. Components refer to these semantic roles instead of choosing a separate look for each page. This keeps cards, controls, tables, charts, work spaces, and code views readable when the active light or dark appearance changes. src/…/globals.css establishes this contract through shared CSS variables and base rules.

The cn helper combines optional class values and resolves conflicting utility classes. It lets a shared component provide a safe default while still allowing a page to adjust its layout for a specific use. src/…/utils.ts provides this common class composition boundary.

References: src/…/globals.css• L12-53 src/…/globals.css• L57-128 src/…/utils.ts• L1-6

Brand presentation

The shared brand mark gives application and dashboard shells one reusable identity element. AppLogo renders the mark as an SVG and accepts normal SVG properties, so each surface can control its size and color without changing the logo shape. Its decorative mark is hidden from assistive technology because nearby text or page structure provides the product meaning. src/…/app-logo.tsx defines this shared presentation helper.

References: src/…/app-logo.tsx• L1-21

Component composition

The UI components expose small building blocks that can be nested into larger page surfaces. A card groups related content, a button expresses an action, and a field joins a label, description, control, and error into one form unit. A code block and a trace provide the same kind of shared surface for technical content and step-by-step activity. src/…/card.tsx, src/…/button.tsx, src/…/field.tsx, src/…/code-block.tsx, and src/…/trace.tsx show the main composition pattern.

Most components accept the props of their underlying HTML element and add a small set of visual or behavior variants. Components can also render through a child element when a page needs to keep its own link or control semantics. This keeps the layer useful for simple screens and complex workspaces while preserving normal browser behavior.

References: src/…/card.tsx• L4-19 src/…/card.tsx• L22-102 src/…/button.tsx• L6-66 src/…/field.tsx• L72-85 src/…/code-block.tsx• L27-43 src/…/trace.tsx• L11-21

Reusable interaction surfaces

The reusable controls cover the common actions and states that appear across product pages. They provide a shared response to input, selection, navigation, loading, errors, empty data, temporary focus, and technical content that users may need to inspect or copy.

Action and content primitives

Action primitives express the intent of a control through shared variants and sizes. Content primitives give pages stable surfaces for grouped information, status messages, attachments, tables, progress, placeholders, code, and traces. Together they make a dashboard summary and an application work area feel like parts of the same product.

The primitives also carry common states such as disabled controls, invalid input, selected rows, focus indication, loading content, upload or processing status, and running or failed trace steps. A page can therefore show its current state without inventing a new visual rule for each feature.

References: src/…/button.tsx• L6-40 src/…/input.tsx• L4-15 src/…/table.tsx• L6-115 src/…/attachment.tsx• L26-45 src/…/attachment.tsx• L95-177 src/…/skeleton.tsx• L3-10 src/…/trace.tsx• L24-41

Navigation and overlay primitives support work that needs more space or temporary focus. The sidebar provides a shared navigation frame with desktop collapse states and a mobile drawer. Dialogs, sheets, popovers, menus, tabs, tooltips, and command surfaces let a page reveal related choices or details without losing its place.

These surfaces share focus, close, and responsive behavior through their component contracts. The sidebar also exposes one context for its open state, which allows triggers and menu parts to coordinate instead of managing separate copies of that state. src/…/sidebar.tsx and src/…/dialog.tsx define these two important patterns.

References: src/…/sidebar.tsx• L34-53 src/…/sidebar.tsx• L55-147 src/…/sidebar.tsx• L151-205 src/…/dialog.tsx• L10-85 src/…/command.tsx• L36-65

Form and feedback primitives

Form primitives turn a control into a clear input group. A field can supply a title, help text, separator, and one or more error messages. Feedback primitives then show alerts, empty results, progress, spinners, skeleton content, and transient notices with the same color and spacing rules.

The goal is to separate the meaning of a state from the page that owns it. An empty data view can explain what is missing and offer an action without requiring every dashboard to design its own empty screen. Questionnaire surfaces extend the same idea to guided multi-step input with choices, progress, errors, and actions.

References: src/…/field.tsx• L10-69 src/…/field.tsx• L88-223 src/…/empty.tsx• L4-103 src/…/alert.tsx• L21-75 src/…/questionnaire.tsx• L10-35 src/…/questionnaire.tsx• L192-305

Conversation and content surfaces

Conversation primitives give chat-like experiences a shared structure for message alignment, avatars, headers, footers, bubbles, reactions, and long-message scrolling. File attachment primitives provide a matching surface for media, file state, actions, and horizontal groups.

Technical content uses related presentation surfaces. Code blocks provide readable, selectable code with optional line numbers, wrapping, line states, and copy feedback. Traces provide compact activity lines with status and expandable detail. These components keep technical output focused on the content while the foundation supplies layout, state, and keyboard-visible focus.

References: src/…/message.tsx• L4-91 src/…/bubble.tsx• L6-124 src/…/message-scroller.tsx• L21-131 src/…/attachment.tsx• L48-204 src/…/code-block.tsx• L87-179 src/…/trace.tsx• L24-149

Presentation helpers

Presentation helpers are shared components and small utilities for recurring display tasks. They sit above the basic primitives and translate common data shapes or technical output into readable controls and visual views.

Date and calendar presentation

Calendar support gives pages one language for choosing dates and showing events. The date-range picker combines a button, popover, and range calendar so a page can accept either its own controlled range or a local range. Event calendar views add shared display rules for day, time, list, and multi-month event views.

The event view surface also keeps event color, focus, selection, resizing, current-day emphasis, dense layouts, and print behavior aligned across calendar modes. Callers provide calendar data and options while the shared view layer supplies the presentation contract. src/…/date-range-picker.tsx and src/…/event-calendar-views.tsx provide these higher-level display surfaces.

References: src/…/date-range-picker.tsx• L12-59 src/…/event-calendar-views.tsx• L73-83 src/…/event-calendar-views.tsx• L89-126 src/…/event-calendar-views.tsx• L399-492

Data and visual display

Charts, tables, icons, and formatting helpers turn records into views that users can scan and compare. The chart surface maps a page-owned data description to shared labels, colors, legends, and tooltips. The table feature registry gives dashboard tables a common set of filtering, sorting, selection, sizing, visibility, and paging capabilities. src/…/chart.tsx and src/…/data-table-features.ts define these shared display contracts.

Small helpers cover repeated values that appear beside those views. getInitials creates a safe avatar fallback and formatCurrency gives financial values a locale-aware display format. src/…/simple-icon.tsx provides an accessible wrapper for brand icons by exposing the icon title to assistive technology.

References: src/…/chart.tsx• L14-80 src/…/chart.tsx• L116-147 src/…/data-table-features.ts• L24-56 src/…/utils.ts• L8-42 src/…/simple-icon.tsx• L8-27

Code and trace presentation

Code presentation turns source text into a readable view without making pages manage syntax state. useHighlightedCode loads a language highlighter when needed, keeps plain text as a fallback, and highlights complete lines incrementally while a code stream grows. The shared highlighter supports named languages and common aliases, while CodeBlock presents the result with selection, optional line numbers, wrapping, line markers, and copy feedback. src/…/use-highlighted-code.ts, src/…/highlighter.tsx, and src/…/code-block.tsx define this relationship.

Trace presentation turns activity into a compact sequence that can show progress, failure, or pending work. A trace line can remain a simple label or become a collapsible branch with a title, description, icon, and detail content. This lets application experiences expose useful process context without forcing every page to build its own activity view. src/…/trace.tsx provides the shared surface.

References: src/…/use-highlighted-code.ts• L5-73 src/…/highlighter.tsx• L6-21 src/…/highlighter.tsx• L61-115 src/…/code-block.tsx• L87-179 src/…/trace.tsx• L24-149

Responsive presentation

Responsive helpers let shared surfaces change their presentation at the same screen boundary as the surrounding page. useIsMobile identifies screens below the mobile boundary and useIsLg identifies large screens. The sidebar uses the mobile helper to switch from a desktop rail to a mobile sheet, while other pages can use the same signals for their own view choices.

This shared boundary matters because a page and its controls must agree about when content moves, collapses, or opens in a temporary surface. A change to a breakpoint can affect both the page composition and the component behavior.

References: src/…/use-mobile.ts• L3-18 src/…/use-lg.ts• L3-18 src/…/sidebar.tsx• L164-205

UI layer relationships

The UI foundation is consumed by route-level experiences rather than owning business workflows. Feature pages choose the records, actions, and page layout; the foundation supplies the common controls and display rules that make those choices consistent.

Child component guide

Read UI components and display helpers for the detailed map of the component inventory, display helpers, responsive hooks, calendar support, data-display capabilities, and technical content surfaces. Use this page first to understand the layer’s role, then use the child page when a change requires a specific component or helper.

References: src/…/button.tsx• L43-66 src/…/sidebar.tsx• L677-702 src/…/date-range-picker.tsx• L17-59 src/…/code-block.tsx• L240-249

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep shared token names in src/…/globals.css aligned with the semantic classes used by UI primitives, chart styling, event calendar views, sidebar styling, code blocks, and traces. A renamed token can silently change every light, dark, or preset view.
  • Keep cn behavior compatible with component defaults. A merge change can alter the final class set in many pages without changing their JSX.
  • Preserve the child composition contract when changing components with asChild, action slots, or overlay triggers. A change can replace the page-owned link or control semantics while the screen still renders.
  • Keep the mobile and large-screen breakpoints as shared contracts. Check both page layouts and components that switch between inline, collapsed, and sheet presentations.
  • Keep chart configuration keys and table feature registration aligned with the helpers that consume them. A mismatch can remove labels, colors, filters, or row models without changing the page’s data.
  • Preserve the controlled and uncontrolled behavior of helpers such as DateRangePicker when changing their state flow. Existing callers may rely on either mode.
  • Keep calendar view overrides merged with the shared defaults. A view-specific change must not remove caller options or common event and navigation states.
  • Preserve the code highlighter’s plain-text fallback and language alias contract when changing code display. Unsupported languages must remain readable, and streamed code must not lose completed highlighted lines.
  • Keep code block copy feedback and trace status semantics tied to accessible labels and visible state. Changes to icons or status styles must not hide the result from keyboard or assistive-technology users.

Important failure modes

TriggerConsequenceGuard
A semantic color or radius token is removed from the global style contractShared controls, charts, calendars, sidebars, code blocks, or traces fall back to missing or incorrect visual valuesKeep token names used by the primitives and preset styles in sync
A sidebar consumer renders controls outside SidebarProviderSidebar hooks throw at runtime and the navigation surface cannot renderKeep sidebar triggers and menu parts inside the provider boundary
A responsive breakpoint changes in one helper but not in a related componentA page can switch layout at a different width from its sidebar or other shared surfaceTreat breakpoint constants as one cross-component contract
A chart is rendered without its chart context or required configurationShared tooltip and legend content cannot resolve labels or colorsWrap chart content in ChartContainer and provide matching configuration keys
A controlled date-range caller does not update the value after onChangeThe picker displays the old range even though the user selected a new oneUse the callback to update the value supplied to the controlled picker
An attachment action is placed below its full-surface triggerClicking an action can activate the attachment instead of the intended actionKeep attachment actions above the trigger layer and preserve their separate controls
A calendar view override replaces the shared view options instead of merging themEvent focus, resize handles, dense layouts, or navigation states can disappear in one calendar modeExtend the shared view defaults and retain the caller’s view options
A requested language is unsupported or its highlighter load failsCode remains uncolored but must still be readable as plain textKeep the fallback path and do not require syntax highlighting for rendering
A streamed code value is highlighted from the start on every updateGrowing output can lose grammar continuity or waste work on completed linesRetain completed line state and tokenize only the new tail
A trace branch omits its collapsible trigger/content relationshipUsers cannot inspect process detail or the branch loses its expected keyboard interactionCompose trace branches through the shared collapsible parts

Key files

FileWhy to read it
src/…/globals.cssDefines the semantic visual contract used by the shared UI layer.
src/…/utils.tsProvides class composition and common value display helpers.
src/…/app-logo.tsxDefines the reusable brand mark used by application and dashboard surfaces.
src/…/button.tsxShows the shared action variants, sizes, states, and element composition pattern.
src/…/card.tsxShows how a content surface is split into composable parts.
src/…/field.tsxShows how form labels, help text, and errors form one reusable unit.
src/…/sidebar.tsxShows the shared navigation surface, responsive switch, and state context.
src/…/dialog.tsxShows the shared temporary focus surface for modal work.
src/…/attachment.tsxShows the shared file surface and its state and action relationship.
src/…/message.tsxShows the shared structure for conversation-oriented content.
src/…/chart.tsxShows the common contract for chart colors, labels, legends, and tooltips.
src/…/code-block.tsxShows the reusable surface for selectable, copyable, and marked code.
src/…/trace.tsxShows the reusable surface for status-bearing and expandable activity.
src/…/use-highlighted-code.tsShows how code highlighting supports language loading and growing output.
src/…/highlighter.tsxDefines supported language loading, aliases, themes, and plain-text-compatible highlighting.
src/…/date-range-picker.tsxShows a higher-level helper built from button, popover, and calendar primitives.
src/…/event-calendar-views.tsxShows shared presentation rules for event calendar views.
src/…/simple-icon.tsxShows the accessible wrapper for brand icons.
src/…/data-table-features.tsDefines the common capabilities expected by dashboard data tables.
docs/ui-components-and-display-helpers.mdProvides the detailed child guide for the UI inventory and presentation helpers.