---
title: "UI patterns"
url: https://memory.wiki/wp12y7sM
updated: 2026-05-16T14:17:17.723Z
hub: https://memory.wiki/hub/demo
bundle_count: 1
concept_count: 12
source: "demo-seed"
---
# UI patterns

## Tailwind 4 conventions

- Design tokens live in `globals.css` as CSS variables: `--background`, `--accent`, `--text-primary`, etc.
- Use `var(--...)` everywhere. Don't hardcode hex.
- Dark mode via `[data-theme="dark"]` on `<html>`. Tokens get re-bound at the document root.

## Component organization

```text
components/
├── atoms/         # Button, Input, Badge — no state, no fetching
├── molecules/     # FormField, Card, Menu — local state OK
├── organisms/     # PageEditor, BlockToolbar — owns fetching
└── primitives/    # shadcn/ui exports (rename to mark these as ours)
```

Rule: atoms can be used everywhere. Organisms can't be imported by
atoms or molecules — only by pages.

## Form validation

Zod schemas live next to the form. `useForm` from React Hook Form.
Server validates the SAME schema. Don't trust client validation
alone — the API enforces it again.

## Loading states

Prefer `<Suspense>` boundaries with skeletons over conditional
`isLoading` ternaries. Skeletons match the final layout so the
viewport doesn't jump.

## Empty states

Every list view has an empty state with: icon + 1-line copy + 1
CTA. Don't ship a blank screen — that's a bug.

## Accessibility

- Every `<button>` has either visible text or `aria-label`
- Color contrast WCAG AA minimum (we use the Tailwind defaults which
  pass AA for body text)
- Keyboard nav works — every interactive element reachable via Tab,
  modal traps focus, Escape closes overlays

## Things to avoid

- No inline styles unless you're animating (transform/opacity only)
- No `!important` — if you need it, the cascade is wrong
- No `onClick` on `<div>` — use `<button>` or `<a>`


---

## Concepts in this document
- **Supabase** _(entity)_
  Backend-as-a-service providing authentication, database, and row-level security without separate auth overhead.
- **Vendor consolidation** _(concept)_
  The operational principle of reducing authentication surfaces, SDKs, and control planes by keeping vector search within the existing Postgres infrastructure.
- **pgvector** _(entity)_
  PostgreSQL extension providing vector data type and HNSW indexing for efficient similarity search.
- **Authentication** _(tag)_
  Core security domain covering user identity, session management, and authorization patterns.
- **Database Design** _(tag)_
  Data modeling domain including schema design, migrations, and query optimization strategies.
- **API Design** _(tag)_
  RESTful interface design covering endpoints, error handling, and client-server communication.
- **Resend** _(entity)_
  Email service provider supporting both transactional and marketing communication channels.
- **Next.js App Router** _(entity)_
  Chosen routing framework leveraging RSC and Server Actions to match the project's data-heavy, read-mostly workload.
- **Vercel AI Gateway** _(entity)_
  AI provider abstraction layer offering failover and zero data retention for model access.
- **Next.js 15** _(entity)_
  Chosen frontend framework leveraging React Server Components and caching for performance.
- **Row-level security** _(concept)_
  Supabase RLS capability co-locating authentication and authorization with data, justifying single-vendor consolidation.
- **React Hook Form** _(entity)_
  Primary form handling library paired with Zod schemas for both client and server validation.

## Concept relations (within this doc's concepts)
- **Supabase** enables approach **Vendor consolidation**
- **Supabase** implements **Row-level security**
- **Supabase** hosts **pgvector**
- **Vercel AI Gateway** similar pattern **Resend**
- **Supabase** exemplifies approach **Vendor consolidation**
- **Row-level security** supports decision **Vendor consolidation**
- **Supabase** reduces complexity **Vendor consolidation**
- **Row-level security** supports **Vendor consolidation**
- **Supabase** integrates **pgvector**
- **Supabase** exemplifies strategy **Vendor consolidation**
- **Supabase** provides **Row-level security**
- **Vendor consolidation** guides **Supabase**
- **Vendor consolidation** guides **Vercel AI Gateway**

## Bundles containing this document
- [Cross-tool dev workflow](https://memory.wiki/b/p_mdtSk0)
  > Acme Pulse, a fictional landing-page builder. The seven docs in this bundle are the project's living context — README, auth pattern, DB schema, API conventions, UI patterns, decision log, open questio

_Hub canonical:_ https://memory.wiki/hub/demo
_Concept digest:_ https://memory.wiki/raw/hub/demo?digest=1&compact=1
