Skip to main content

Layouts

Relevant source files This document covers the Layer 3 layout components in the @ui8kit/core architecture: DashLayout, LayoutBlock, and SplitBlock. These are template-level components (organisms) that orchestrate Layer 2 UI components and Layer 1 primitives into structural page layouts. This page focuses on layout composition patterns, content hook systems, and special considerations for building application structures. For basic layout primitives (Grid, Flex, Stack), see Core Components.
For UI components used within layouts, see UI Components.
For API details and prop references, see Layout Components API.

Layout Architecture Overview

The layout system operates at the highest architectural layer, composing UI components and primitives into complete page structures. The three layout components serve distinct structural purposes:
Sources: src/layouts/DashLayout.tsx1-99 src/layouts/LayoutBlock.tsx1-389 src/layouts/SplitBlock.tsx1-145 README.md147-168

DashLayout - Dashboard Template

DashLayout provides a complete dashboard structure with resizable panels, navigation header, and collapsible sidebar. It uses react-resizable-panels for interactive panel management.

Component Structure

Key Interfaces and Props

Implementation Details

The Dashboard component at src/layouts/DashLayout.tsx64-91 orchestrates the layout:
  1. Navbar renders at top with theme toggle at src/layouts/DashLayout.tsx34-49
  2. PanelGroup with direction="horizontal" creates resizable layout at src/layouts/DashLayout.tsx75-88
  3. Panel components define sidebar (20% default, 10-40% range) and content area (80% default, 50% minimum) at src/layouts/DashLayout.tsx76-86
  4. PanelResizeHandle enables interactive resizing at src/layouts/DashLayout.tsx80
  5. Container wraps main content with responsive sizing at src/layouts/DashLayout.tsx84

Usage Pattern

The layout automatically persists panel sizes via autoSaveId="dashlayout-panels" at src/layouts/DashLayout.tsx75 Sources: src/layouts/DashLayout.tsx1-99 README.md155-168

LayoutBlock - Flexible Content Sections

LayoutBlock is a versatile layout component that renders content sections with three layout modes (grid, flex, stack) and a powerful content hook system for dynamic rendering.

Layout Modes and Configuration

Content Hook System

The content hook system at src/layouts/LayoutBlock.tsx22-30 allows replacing any part of the rendered content:

Default Renderers

The component provides default renderers at src/layouts/LayoutBlock.tsx123-227:

Configuration Props

Content Data Structure

The content prop at src/layouts/LayoutBlock.tsx61-77 follows this schema:

Layout Mode Rendering

The rendering logic at src/layouts/LayoutBlock.tsx298-353 selects the appropriate layout component:
Each layout wraps items in the appropriate primitive component with data-class attributes for DOM targeting at src/layouts/LayoutBlock.tsx320-348

Usage Examples

Grid with Cards:
Flex with Custom Hooks:
Sources: src/layouts/LayoutBlock.tsx1-389 README.md149-154

SplitBlock - Two-Column Split Layout

SplitBlock creates two-column layouts with flexible media and content sections, commonly used for hero sections, feature showcases, and content/image combinations.

Layout Modes

Content Hook System

Similar to LayoutBlock, SplitBlock supports content hooks at src/layouts/SplitBlock.tsx11-15:

Slots API

The slots API at src/layouts/SplitBlock.tsx36-42 provides named overrides:
The media slot resolution at src/layouts/SplitBlock.tsx91 prioritizes slot overrides over direct props.

Configuration Props

Layout Rendering Logic

The rendering logic at src/layouts/SplitBlock.tsx94-136 creates two distinct layouts: Container Mode (splitSection=false) at src/layouts/SplitBlock.tsx96-111:
  • Wraps grid in responsive Container
  • Applies containerSize and padding props
  • Suitable for standard page sections
Full Width Mode (splitSection=true) at src/layouts/SplitBlock.tsx115-135:
  • Grid directly after Block with no container
  • Uses data-class="split-grid" for identification at src/layouts/SplitBlock.tsx129
  • Applies flex-1 items-center for full viewport height

Column Order

The column order is determined by leftMedia prop at src/layouts/SplitBlock.tsx106-107 and src/layouts/SplitBlock.tsx131-132:
  • leftMedia=true: [mediaSection, contentSection]
  • leftMedia=false: [contentSection, mediaSection]

Usage Examples

Basic Split with Media:
With Content Hooks:
Full Width Hero:
Sources: src/layouts/SplitBlock.tsx1-145 README.md149-154

Layout Primitives Integration

Layout components extensively use Layer 1 primitives for structure. Understanding these primitives is essential for working with layouts.

Grid Component

Used by LayoutBlock (grid mode) and SplitBlock for CSS Grid layouts:
Common Grid Configurations:
  • cols="1-2-3" - Responsive 1/2/3 columns
  • cols="2" - Fixed 2 columns
  • gap="lg" - Large gap between items
  • align="center" - Center items vertically

Stack Component

Used by LayoutBlock (stack mode) and within content sections for vertical layouts:

Block Component

All layout components use Block as the root semantic container:
The component prop at src/layouts/DashLayout.tsx16 src/layouts/DashLayout.tsx36 and src/layouts/DashLayout.tsx74 ensures semantic HTML structure (<section>, <nav>, <aside>, <main>). Sources: src/layouts/LayoutBlock.tsx3-16 src/layouts/SplitBlock.tsx3-8 src/layouts/DashLayout.tsx2

Composition Patterns

Layout components follow specific composition patterns for building complex structures.

Pattern 1: Nested Layout Composition

Layouts can be nested to create complex page structures:
Example:

Pattern 2: Container Management

Layouts use Container component for responsive width control:

Pattern 3: Content Hook Override

The content hook system enables progressive enhancement:
Fallback Chain:
  1. Check for custom contentHooks.item at src/layouts/LayoutBlock.tsx302
  2. Fall back to default renderer at src/layouts/LayoutBlock.tsx285
  3. Apply layout-specific defaults at src/layouts/LayoutBlock.tsx230-254

Pattern 4: Slot-Based Overrides

SplitBlock slots provide targeted customization without full content hooks:
The resolution at src/layouts/SplitBlock.tsx91 prioritizes slots over direct props.

Pattern 5: Data-Driven Rendering

Layouts accept structured data and render automatically:
The rendering pipeline at src/layouts/LayoutBlock.tsx288-361 handles:
  1. Header rendering from content.badge/title/description
  2. Item iteration and rendering from content.items
  3. Layout wrapping based on layout mode
Sources: src/layouts/LayoutBlock.tsx256-386 src/layouts/SplitBlock.tsx67-143 src/layouts/DashLayout.tsx64-91

Special Considerations

Semantic HTML Structure

Layout components enforce semantic HTML5 structure: This ensures accessibility and SEO compliance without additional configuration.

Data-Class Attributes

All layouts apply data-class attributes for consistent DOM targeting: These enable reliable testing and styling without className dependencies.

Responsive Behavior

Layouts handle responsive design through variant props: Grid Responsive Columns:
  • cols="1-2-3" creates mobile→tablet→desktop breakpoints
  • Automatically collapses to 1 column on mobile
  • Scales to 2 columns on tablet (md:)
  • Expands to 3 columns on desktop (lg:)
Container Responsive Sizing:
  • containerSize="lg" applies max-w-7xl with breakpoint adjustments
  • Automatically adds horizontal padding on mobile
  • Centers content with mx="auto"
Panel Resizing (DashLayout):

Performance Considerations

Item Key Management: The LayoutBlock component requires unique id in content items at src/layouts/LayoutBlock.tsx66 for efficient React reconciliation. Keys are applied at src/layouts/LayoutBlock.tsx306 Memoization Opportunities: Content hooks and renderers are evaluated on every render. For expensive computations, wrap in useMemo:
Panel State Persistence: DashLayout automatically persists panel sizes to localStorage via react-resizable-panels, reducing layout shift on reload.

External Dependencies

These are listed as peer dependencies and must be installed separately when using layouts. Sources: src/layouts/DashLayout.tsx4 src/layouts/LayoutBlock.tsx366-383 src/layouts/SplitBlock.tsx94-136

Usage Examples

Dashboard Application

Complete dashboard with navigation, resizable panels, and content sections:

Marketing Landing Page

Hero section with split layout and feature grid:

Content-Heavy Article Layout

Stack layout with custom content hooks for rich content:
Sources: README.md36-168 src/layouts/DashLayout.tsx53-96 src/layouts/LayoutBlock.tsx256-389 src/layouts/SplitBlock.tsx67-143