[**Documentation**](../../../README)

***

[Documentation](../../../README) / [zerotal](../../README) / [view](../README) / defineLayout

# Function: defineLayout()

> **defineLayout**\<`LP`\>(`Layout`): \<`PP`\>(`Page`) => (`props`) => [`SafeHtml`](../classes/SafeHtml)

Defined in: [packages/core/src/view/index.ts:131](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/view/index.ts#L131)

Bind a shared layout component to page components, eliminating the need
to wrap every page in `<Layout>...</Layout>` manually.

Returns a `wrap` factory.  Call `wrap(PageComponent)` to produce a new
component that renders `PageComponent` inside the layout.  All props from
both the layout (except `children`) and the page are merged — TypeScript
enforces that callers supply every required field.

## Type Parameters

### LP

`LP` *extends* `Record`\<`string`, `unknown`\>

## Parameters

### Layout

(`props`) => [`SafeHtml`](../classes/SafeHtml)

## Returns

\<`PP`\>(`Page`) => (`props`) => [`SafeHtml`](../classes/SafeHtml)

## Example

```ts
// resources/views/layouts/AppLayout.tsx
export function AppLayout({ children, title }: { children: unknown; title: string }) {
  return (
    <html>
      <head><title>{title} — My App</title></head>
      <body>{children}</body>
    </html>
  );
}

// resources/views/About.tsx
import { defineLayout } from '@zerotal/core';
import { AppLayout }    from './layouts/AppLayout.tsx';

const wrap = defineLayout(AppLayout);

export const AboutPage = wrap<{ title: string }>(({ title }) => (
  <main>
    <h1>{title}</h1>
    <p>We build things.</p>
  </main>
));

// In routes/index.ts:
Router.view('/about', AboutPage, { title: 'About Us' });
```
