Skip to main content
zerotal

Documentation


Documentation / @zerotal/flow / index / Layout

Abstract Class: Layout

Defined in: flow/src/Layout.ts:35

Base class for Flow page layouts — persistent shell UI wrapped around page content.

Remarks

A layout wraps page content with shell UI (nav, sidebars, footers) that outlives page navigation. On flow:navigate, pages that share the same layout class only swap their [data-flow-root] content; the layout shell stays mounted and is never re-rendered or re-sent over the socket. Attach one with static layout = AppLayout on a Component (or override Component.layout for the JSX-native form).

Example

export class AppLayout extends Layout {
  static head = `<link rel="stylesheet" href="/app.css">`;

  render(slot: HtmlNode) {
    return (
      <div>
        <nav>
          <a href="/dashboard" flow:navigate>Dashboard</a>
        </nav>
        <main>{slot}</main>
      </div>
    );
  }
}

export class DashboardPage extends Component {
  static layout = AppLayout;
}

Extended by

Constructors

Constructor

new Layout(): Layout

Returns

Layout

Properties

static optional head?: string

Defined in: flow/src/Layout.ts:37

Extra HTML injected into <head> (stylesheets, fonts, global meta tags).

Methods

render()

abstract render(slot): HtmlNode | Promise<HtmlNode>

Defined in: flow/src/Layout.ts:46

Render the layout shell around a page.

Parameters

slot

HtmlNode

the page's pre-rendered [data-flow-root] component node. Place it with {slot} in JSX — its HTML is emitted verbatim without escaping.

Returns

HtmlNode | Promise<HtmlNode>

the shell markup wrapping slot.