---
title: "Page · Base UI — StyleX Blocks"
description: "Page scaffolds with header, title, description, and body in panel and settings variants."
url: "https://stylexblocks.com/components/base-ui/page/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Page

Page scaffolds with header, title, description, and body in panel and settings variants.

- Behavior engine: Base UI
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/page.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/page.md)
- Category: Layout
- Variants: panel, settings
- HTML page: https://stylexblocks.com/components/base-ui/page/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style base-ui
```

Then add the item as source you own:

```sh
npx stylexblocks add page
```

Equivalent: `npx shadcn add @stylexblocks/page`. Registry item JSON: https://stylexblocks.com/r/base-ui/page.json

## Usage

```tsx
import { Page } from "#components/ui/base-ui/page.tsx";

export function Example() {
  return (
    // variant resolves once on Root; every part inherits it via context —
    // composition per part via render
    <Page.Root variant="panel">
      <Page.Header>
        <Page.HeaderContent>
          <Page.Heading>
            <Page.Title>Dashboard</Page.Title>
            <Page.Description>Overview of your workspace.</Page.Description>
          </Page.Heading>
        </Page.HeaderContent>
      </Page.Header>
      <Page.Body>…</Page.Body>
    </Page.Root>
  );
}
```

## Source

`components/ui/base-ui/page.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createSlotRecipeContext } from "#lib/base-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { fontWeights } from '@stylexblocks/ui/tokens/font-weights.stylex.ts'
import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const pageRoot = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    flex: 1,
    minHeight: 0,
  },
})

const pageRootVariants = stylex.create({
  panel: {
    '--page-bg-color': semanticColors.bg,
    backgroundColor: 'var(--page-bg-color)',
    zIndex: 1,
  },
  settings: {
    overflowY: 'auto',
    paddingInline: spacing._4,
  },
})

const pageHeader = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    flexShrink: 0,
  },
})

const pageHeaderVariants = stylex.create({
  panel: {
    '--page-header-row-height': '40px',
    '--page-header-padding-x': spacing._4,
    borderBottomWidth: '1px',
  },
  settings: {},
})

const pageHeaderContent = stylex.create({
  base: {
    display: 'flex',
    flex: 1,
    alignItems: 'center',
    gap: spacing._2,
    minWidth: 0,
  },
})

const pageHeaderContentVariants = stylex.create({
  panel: {
    minHeight: 'var(--page-header-row-height)',
    paddingInline: 'var(--page-header-padding-x)',
  },
  settings: {
    minHeight: sizes._24,
  },
})

const pageHeading = stylex.create({
  base: {
    flex: 1,
    minWidth: 0,
  },
})

const pageHeadingVariants = stylex.create({
  settings: {},
})

const pageHeaderFooter = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    width: sizes.full,
  },
})

const pageTitle = stylex.create({
  base: {
    fontWeight: fontWeights.medium,
  },
})

const pageTitleVariants = stylex.create({
  panel: {
    marginInlineEnd: spacing._4,
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
  },
  settings: {
    fontSize: fontSizes._2xl,
    lineHeight: lineHeights._2xl,
  },
})

const pageDescription = stylex.create({
  base: {
    color: semanticColors.fgMuted,
  },
})

const pageDescriptionVariants = stylex.create({
  panel: {
    fontSize: fontSizes.xs,
    lineHeight: lineHeights.xs,
  },
  settings: {
    fontSize: fontSizes.md,
    lineHeight: lineHeights.md,
  },
})

const pageBody = stylex.create({
  base: {
    flex: 1,
    overflowY: 'auto',
    padding: spacing._4,
  },
})

const pageBodyVariants = stylex.create({
  settings: {
    overflow: 'visible',
    padding: 0,
  },
})

export type PageVariant = keyof typeof pageRootVariants

// defineSlotRecipe validates the shape at compile time: default values must
// exist in the axis maps, and slot keys must be `styles` or a declared axis.
// The heading and body variant maps are sparse (only `settings` restyles
// them) — the mechanical resolver skips axis values a slot doesn't style.
const pageSlotRecipe = defineSlotRecipe({
  slots: {
    root: { styles: pageRoot, variants: pageRootVariants },
    header: { styles: pageHeader, variants: pageHeaderVariants },
    headerContent: {
      styles: pageHeaderContent,
      variants: pageHeaderContentVariants,
    },
    heading: { styles: pageHeading, variants: pageHeadingVariants },
    headerFooter: { styles: pageHeaderFooter },
    title: { styles: pageTitle, variants: pageTitleVariants },
    description: { styles: pageDescription, variants: pageDescriptionVariants },
    body: { styles: pageBody, variants: pageBodyVariants },
  },
  defaultVariants: { variant: "panel" },
});

/**
 * Page — recipe and component colocated in one file. `<Page.Root variant>`
 * resolves the recipe once and every part inherits it through context; each
 * part composes via `render`.
 */
const { withProvider, withContext } = createSlotRecipeContext(pageSlotRecipe);

export const Page = {
  // slot names resolve mechanically from the recipe maps above
  Root: withProvider("main", "root", "PageRoot"),
  Header: withContext("header", "header", "PageHeader"),
  HeaderContent: withContext("div", "headerContent", "PageHeaderContent"),
  Heading: withContext("div", "heading", "PageHeading"),
  HeaderFooter: withContext("div", "headerFooter", "PageHeaderFooter"),
  Title: withContext("h1", "title", "PageTitle"),
  Description: withContext("p", "description", "PageDescription"),
  Body: withContext("div", "body", "PageBody"),
};
```
