# Section Layout

Page heading with its own sub-navigation, such as settings or account pages.

Page: https://sui.draco.dev/docs/layouts/section-layout

Adapted from the shadcn-admin settings page. The sections are [Tabs](/docs/components/tabs) in a side column from the `lg` breakpoint, on a rail between them and the content. The column is a fifth of the page wide but held between 192 and 256px; below `lg` the tabs are a scrolling row above the content. Choosing one calls the layout's `onNavigate`, and the tabs take their accessible name from `title`.

### Example: layout-section

```tsx
"use client";

import { LayoutProvider } from "@workspace/ui/layouts/layout-provider";
import { SectionLayout } from "@workspace/ui/layouts/section-layout";
import { Bell, Monitor, Palette, UserCog, Wrench } from "lucide-react";
import { useDemoRouter } from "../support/layout-router";
import type { ExampleProps } from "../types";

export default function LayoutSection({ locale }: ExampleProps) {
  const zh = locale === "zh-CN";
  const router = useDemoRouter("/settings");
  const items = [
    { title: zh ? "个人资料" : "Profile", href: "/settings", icon: UserCog },
    { title: zh ? "账户" : "Account", href: "/settings/account", icon: Wrench },
    {
      title: zh ? "外观" : "Appearance",
      href: "/settings/appearance",
      icon: Palette,
    },
    {
      title: zh ? "通知" : "Notifications",
      href: "/settings/notifications",
      icon: Bell,
    },
    {
      title: zh ? "显示" : "Display",
      href: "/settings/display",
      icon: Monitor,
    },
  ];
  const current = items.find((item) => item.href === router.currentPath);
  return (
    <LayoutProvider {...router}>
      <SectionLayout
        className="w-full rounded-xl border p-6"
        title={zh ? "设置" : "Settings"}
        description={
          zh
            ? "管理账户设置和邮件偏好。"
            : "Manage your account settings and email preferences."
        }
        items={items}
      >
        <h2 className="font-medium text-lg">{current?.title}</h2>
        <div className="mt-4 h-48 rounded-2xl bg-muted/40" />
      </SectionLayout>
    </LayoutProvider>
  );
}
```

## Installation

```bash
npx shadcn@latest add @sui/section-layout
```

With pnpm, Yarn or Bun, use `pnpm dlx`, `yarn dlx` or `bunx --bun` in place of `npx`, and `pnpm add`, `yarn add` or `bun add` in place of `npm install`.

## Usage

```tsx
import { SectionLayout } from "@workspace/ui/layouts/section-layout"

<AppMain fixed>
  <SectionLayout title="Settings" description="Manage your account." items={items}>
    <Outlet />
  </SectionLayout>
</AppMain>
```

Inside an `AppShell`, links and active state come from its `currentPath` and `linkComponent`. Elsewhere, wrap the page in `LayoutProvider` with the same props.

## Horizontal

`orientation="horizontal"` shows the tabs between the heading and the content at every size; they scroll when they outgrow the page. Use it for a few short sections.

### Example: layout-section-horizontal

```tsx
"use client";

import { LayoutProvider } from "@workspace/ui/layouts/layout-provider";
import { SectionLayout } from "@workspace/ui/layouts/section-layout";
import { Bell, Monitor, Palette, UserCog, Wrench } from "lucide-react";
import { useDemoRouter } from "../support/layout-router";
import type { ExampleProps } from "../types";

export default function LayoutSectionHorizontal({ locale }: ExampleProps) {
  const zh = locale === "zh-CN";
  const router = useDemoRouter("/settings");
  const items = [
    { title: zh ? "个人资料" : "Profile", href: "/settings", icon: UserCog },
    { title: zh ? "账户" : "Account", href: "/settings/account", icon: Wrench },
    {
      title: zh ? "外观" : "Appearance",
      href: "/settings/appearance",
      icon: Palette,
    },
    {
      title: zh ? "通知" : "Notifications",
      href: "/settings/notifications",
      icon: Bell,
    },
    {
      title: zh ? "显示" : "Display",
      href: "/settings/display",
      icon: Monitor,
    },
  ];
  const current = items.find((item) => item.href === router.currentPath);
  return (
    <LayoutProvider {...router}>
      <SectionLayout
        className="w-full rounded-xl border p-6"
        title={zh ? "设置" : "Settings"}
        description={
          zh
            ? "管理账户设置和邮件偏好。"
            : "Manage your account settings and email preferences."
        }
        orientation="horizontal"
        items={items}
      >
        <h2 className="font-medium text-lg">{current?.title}</h2>
        <div className="mt-4 h-48 rounded-2xl bg-muted/40" />
      </SectionLayout>
    </LayoutProvider>
  );
}
```

## API

| Prop | Default | Description |
| --- | --- | --- |
| `title` | Required | Page heading. |
| `description` | — | Text under the heading. |
| `actions` | — | Controls for every section, such as a date range or a primary action, at the end of the heading row. |
| `items` | Required | Links `{ title, href, icon?, disabled? }`. |
| `orientation` | `"vertical"` | `"vertical"` stands the tabs in a side column from `lg` up; `"horizontal"` keeps them above the content. |

The content is a flex column, so a list in a fixed-height AppMain scrolls inside it and keeps its pagination in view.

`SectionTabs` renders the tabs alone, with `orientation` for a column. `SectionNav` renders the earlier link navigation: links from `lg` up, a scrolling row on tablets and a select on phones.
