# Implementation — Header / Footer
### Rules
1. **Edit `appLayout.tsx` only** — header and footer are layout-level concerns. Never add them to individual page files.
2. **Never modify `routes.tsx` or `app.tsx`** — the router setup must remain intact.
3. **Create component files in `src/components/layout/`** — the designated location for layout-level components.
4. **Use the full-height flex column pattern** — wrap layout in `min-h-screen flex flex-col` so footer stays at bottom.
5. **Use shadcn and Tailwind** — compose from `@/components/ui`; style with Tailwind utility classes and design tokens.
6. **Use path aliases** — import with `@/components/layout/...` and `@/components/ui`; no deep relative paths.
7. **Preserve existing content** — if `appLayout.tsx` already has a `` or other shell elements, keep them in place.
### Step 1 — Create the header component (if requested)
Create `src/components/layout/AppHeader.tsx`:
```tsx
import { cn } from "@/lib/utils";
interface AppHeaderProps {
className?: string;
}
export function AppHeader({ className }: AppHeaderProps) {
return (
My App
);
}
```
### Step 2 — Create the footer component (if requested)
Create `src/components/layout/AppFooter.tsx`:
```tsx
import { cn } from "@/lib/utils";
interface AppFooterProps {
className?: string;
}
export function AppFooter({ className }: AppFooterProps) {
return (
);
}
```
### Step 3 — Edit `appLayout.tsx`
Open `src/appLayout.tsx` — this is the **only file to modify** for layout-level additions. Wrap existing content in a flex column and add header above and footer below ``:
```tsx
import { Outlet } from "react-router";
import { AppHeader } from "@/components/layout/AppHeader";
import { AppFooter } from "@/components/layout/AppFooter";
// Keep all existing imports unchanged
export default function AppLayout() {
return (
{/* Keep any existing NavigationMenu or other shell elements here */}
);
}
```
### File Locations — Header / Footer
| Component | File | Export |
| ------------ | ------------------------------------- | ------------------------------ |
| Header | `src/components/layout/AppHeader.tsx` | Named export |
| Footer | `src/components/layout/AppFooter.tsx` | Named export |
| Layout shell | `src/appLayout.tsx` | Default export (edit in place) |
### Why `appLayout.tsx` — Not Pages or Routes
`AppLayout` is the single shell rendered at the root route. Every page is a child rendered via ``. Placing the header and footer here ensures they appear on every page without touching individual pages or the route registry.
```
AppLayout (appLayout.tsx)
├── AppHeader ← renders on every page
├── NavigationMenu ← keep if already present
├── ← active page renders here
└── AppFooter ← renders on every page
```
### Useful Patterns — Header / Footer
- **Sticky header:** add `sticky top-0 z-50` to the `` element
- **Separator:** use `` from `@/components/ui` instead of `border-b`/`border-t` if a visible divider is preferred
- **Nav links in header:** use `