---
name: model-ui
description: >-
  Config-driven, paper-and-ink React / Next.js design system (`model-ui`, github:akoladeolu/model-ui)
  with typed `defineSiteConfig`, 11-step ink opacity ramp, luminance-balanced brand accents,
  zero-flash Dark Mode, and drop-in templates for Home, Blog Index, Blog Post Article, and
  Project Case Study pages. Use whenever building, extending, styling, or configuring portfolios,
  blogs, case studies, or components with `model-ui`.
---

# Model UI (`model-ui`)

**Model UI** (`github:akoladeolu/model-ui`) is a tactile paper-and-ink React / Next.js App Router design system built for AI agents and humans. It pairs monochrome paper surfaces (`#efefef` warm paper, `#fbfbfb` reading canvas, `#0d0e0e` dark stage) and an 11-step ink opacity ramp with a Zod-validated `defineSiteConfig` layer, zero-flash Dark Mode, and 4 complete page templates.

For complete TypeScript prop interfaces (`SiteConfig`, `Project`, `Post`, primitives, blocks, templates, client islands) and `--t-*` CSS custom properties, read [references/api-and-tokens.md](./references/api-and-tokens.md).

---

## 1. Installation

If `model-ui` is not yet in `package.json`, install it directly from GitHub:

```bash
npm install github:akoladeolu/model-ui
# or with pnpm:
pnpm add github:akoladeolu/model-ui
```

---

## 2. Ten Non-Negotiable Aesthetic Rules

1. **Hierarchy is opacity, never hue.** Use the 11-step ink opacity ramp (`--t-ink-3` through `--t-ink-80`) on paper (`--t-bg: #efefef`, `--t-bg-reading: #fbfbfb` in light mode; `#0d0e0e` and `#111212` in dark mode). Never invent gray hex codes.
2. **Strict Accent Restraint.** `--t-brand-accent` and its alpha derivatives (`--t-brand-accent-wordmark`, `--t-brand-accent-ring`, `--t-brand-accent-selection`) are **ONLY** used on 4 micro-moments:
   - The giant cropped footer `<Wordmark />`
   - The `<Clock />` status dot
   - `::selection` text highlight
   - `:focus-visible` keyboard focus rings
   **Never** color buttons, pills, chips, headings, badges, or cards with the brand accent.
3. **Config travels as props + server CSS vars, never React Context.** Pass `config: SiteConfig` from `src/site.config.ts` directly into `<ThemeStyle config={config} />` and template/block props so layouts and content remain Server Components.
4. **Two canvas surfaces.** Home (`/`) and Case Studies (`/projects/[slug]`) use warm paper (`surface="paper"` / `--t-bg`). Blog Index (`/blog`) and Blog Articles (`/blog/[slug]`) use brighter reading paper (`surface="reading"` / `--t-bg-reading`).
5. **Two vertical dashed rail widths.** Home and Blog pages use narrow rails (`rails="narrow"`, `25rem` inset). Case Study pages use wide rails (`rails="wide"`, `10rem` inset) around an `896px` column.
6. **Three type voices, never mixed.**
   - `--t-font-sans` (`-0.3px` body tracking; `-0.06em` display tracking with `0.8` line-height)
   - `--t-font-hand` (`Caveat`, used via `<Statement>`, `<ScriptHeading>`, and `.t-blog-hero__title`)
   - `--t-font-prose` (`Piazzolla`, used inside `<Prose>` article headings)
7. **Tactile physical objects.** Inline `<Sticker>` icons sit mid-sentence at `-7deg` rotation with a `3px` frame border. `<Polaroids>` fan from `-10deg` to `+8deg` and un-tilt on hover with word-by-word blur-reveal pill captions. Project cards sit inside inset wells (`.t-card__well`) that round from `0px` to `24px` (`1.5rem`) on hover.
8. **Hatched section dividers.** Separate major home sections with `<HatchDivider />` (`64px` tall, `-45deg` 1px hatch between horizontal long-dash rules).
9. **Fit-to-width footer wordmark.** Always render the footer watermark with `<Wordmark text={config.brand.wordmark} />`, which sets `--chars` to the grapheme count and scales cleanly up to 12 characters using `calc(96cqi / (var(--chars) * 0.56))`.
10. **Zero-flash Dark Mode.** Always place `<ThemeStyle config={siteConfig} />` inside `<head>` (`<html suppressHydrationWarning>`) and wrap `<body className="t-body t-root">` children in `<ThemeProvider defaultMode={siteConfig.theme.defaultMode}>` from `model-ui/client`.

---

## 3. Entry Points & Component Selector

- **`model-ui`** (Server-safe entry point):
  - **Config**: `defineSiteConfig`, `siteConfigSchema`, `ACCENT_PRESETS`, `PRESET_NAMES`, `resolveAccent`, `toCssVars`, `toCssVarStyleText`
  - **Primitives**: `ThemeStyle`, `Page`, `Column`, `Rails`, `Section`, `HatchDivider`, `Button`, `Pill`, `Chip`, `Badge`, `Eyebrow`, `Display`, `ScriptHeading`, `MonoMeta`, `Prose`, `Panel`, `Sticker`, `Wordmark`, `cx`
  - **Blocks**: `SiteShell`, `DockNav`, `Hero`, `ArcGallery`, `Statement`, `Polaroids`, `ContributionHeatmap`, `PostList`, `Footer`, `Pagination`
  - **Templates**: `HomeTemplate`, `BlogIndexTemplate`, `BlogPostTemplate`, `CaseStudyTemplate`
- **`model-ui/client`** (`"use client"` islands):
  - `ThemeProvider`, `ThemeToggle`, `useTheme`, `applyDomTheme`, `readDomTheme`
  - `Clock` (hydration-safe IANA timezone ticker)
  - `SegmentedFilter`, `FilterPills`, `FilterableProjectGrid`, `FilterableBlogFeed`
  - `ActionOrbs`, `EngageBar`, `ShareModal`, `CommentThread`, `ArticleInteractiveShell`
- **`model-ui/styles.css`**: Full token + component stylesheet (`.t-*` namespace, includes Caveat & Piazzolla variable fonts).
- **`model-ui/tokens.css`**: Standalone design tokens stylesheet.
- **`model-ui/tailwind.css`**: Optional Tailwind CSS v4 `@theme` layer.

---

## 4. Next.js App Router Setup & Canonical Page Recipes

### Step 1: `src/site.config.ts`

```ts
import { defineSiteConfig } from "model-ui";

export const siteConfig = defineSiteConfig({
  brand: {
    name: "Akolade",
    logo: "akolade.",
    monogram: "AO",
    wordmark: "akolade", // max 12 graphemes; auto-scales via CSS container queries
    tagline: "Design engineer building tactile interfaces and thoughtful systems.",
    footerHeadline: "Let's build something people actually use.",
    footerCtaLabel: "Get in touch",
  },
  location: {
    city: "LAGOS",
    timeZone: "Africa/Lagos",
    locale: "en-GB",
  },
  theme: {
    accent: "cyan", // "lime" | "cyan" | "amber" | "violet" | "mono" | { hex: "#ff5c00" }
    defaultMode: "system", // "light" | "dark" | "system"
  },
  nav: [
    { label: "projects", href: "/#projects" },
    { label: "blog", href: "/blog" },
  ],
  socials: {
    github: "https://github.com/akoladeolu",
    x: "https://x.com/akoladeolu",
    email: "hello@example.com",
  },
  seo: {
    siteUrl: "https://example.com",
  },
});
```

### Step 2: `src/app/layout.tsx`

```tsx
import type { ReactNode } from "react";
import { ThemeStyle } from "model-ui";
import { ThemeProvider } from "model-ui/client";
import "model-ui/styles.css";
import { siteConfig } from "@/site.config";

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <head>
        <ThemeStyle config={siteConfig} />
      </head>
      <body className="t-body t-root">
        <ThemeProvider defaultMode={siteConfig.theme.defaultMode}>
          {children}
        </ThemeProvider>
      </body>
    </html>
  );
}
```

### Step 3: Canonical Page Templates

- **Home (`src/app/page.tsx`)**:
  ```tsx
  import { HomeTemplate } from "model-ui";
  import { siteConfig } from "@/site.config";
  import { projects, posts } from "@/content/data";

  export default function HomePage() {
    return <HomeTemplate config={siteConfig} projects={projects} posts={posts} />;
  }
  ```
- **Blog Index (`src/app/blog/page.tsx`)**:
  ```tsx
  import { BlogIndexTemplate } from "model-ui";
  import { siteConfig } from "@/site.config";
  import { posts } from "@/content/data";

  export default function BlogPage() {
    return <BlogIndexTemplate config={siteConfig} posts={posts} />;
  }
  ```
- **Blog Post Article (`src/app/blog/[slug]/page.tsx`)**:
  ```tsx
  import { BlogPostTemplate } from "model-ui";
  import { siteConfig } from "@/site.config";

  export default function ArticlePage({ post, comments }) {
    return (
      <BlogPostTemplate config={siteConfig} post={post} comments={comments}>
        <p>Rich text or MDX content renders inside .t-prose...</p>
      </BlogPostTemplate>
    );
  }
  ```
- **Project Case Study (`src/app/projects/[slug]/page.tsx`)**:
  ```tsx
  import { CaseStudyTemplate } from "model-ui";
  import { siteConfig } from "@/site.config";

  export default function CaseStudyPage({ project }) {
    return <CaseStudyTemplate config={siteConfig} project={project} />;
  }
  ```

---

## 5. Anti-Patterns (Never Do These)

- **Do not** hardcode brand names, cities, timezones, or raw accent hex codes (`#bef264`, `#22d3ee`) inside components or page templates; read from `siteConfig`.
- **Do not** apply `--t-brand-accent` to buttons, badges, pills, headings, or cards.
- **Do not** render `new Date().toLocaleString()` directly during SSR in a Server Component — use `<Clock />` from `model-ui/client`.
- **Do not** use `Math.random()` inside Server Components (`<ContributionHeatmap />` uses a deterministic hash).
- **Do not** exceed 12 graphemes for `brand.wordmark` (`siteConfigSchema` enforces max 12 graphemes so the footer wordmark stays bold and overflow-free).

---

## 6. Mobile Responsiveness Guardrails

- **Never wrap `.t-segmented` onto multiple rows:** Always keep segmented pill controls on a single horizontal row (`flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;`) with `white-space: nowrap; flex-shrink: 0;` items so `border-radius: 9999px` never balloons into a multi-line oval on mobile.
- **Fit inside `360px` viewports:** Floating bars, docks, and modals must stay within `calc(100vw - 1.5rem)` with zero horizontal page overflow (`scrollWidth <= innerWidth`).
- **20px mobile gutter & 2-line titles:** Keep `--t-gutter: 1.25rem` below `640px` and allow `.t-post__title` to wrap up to 2 lines instead of single-line truncation.
- **Verify both viewports:** Always verify UI changes at `1280×800` (Desktop) and `375×812` (Mobile).
