Skip to main content
Brand and assets
Build
Monitor and contribute
/
Front-end platform
  • Overview
  • Technical architecture
  • Core framework
  • Application
  • global-shell
  • modular-arch
  • Product shells
  • Modules & apps
  • Module directory
  • Apps
  • Bundles
  • Bundle explorer
  • Guides
  • Install Murray
  • Universal components
  • Build a universal component
  • Responsive styles
  • RTL support
  • Translations & i18n
  • When to use Form
  • Positioning elements
  • Add a new icon
  • Utilities
  • Overview
  • Layouts
  • Layouts

Layouts

Layouts are reusable view structures with named slots — insertion points where content is projected via React portals. They are created with makeLayout and consumed via ScreenWithLayout in module screen definitions.

Source: frontend/shared/murray/src/utilities/Layout.tsx

Creating a layout​

import { makeLayout, type LayoutDefinition, type LayoutUtilities } from "murray/utilities";

const myLayoutDef: LayoutDefinition<{ children: React.ReactNode; titleKey: string }> = {
Component: ({ children, titleKey, Slot }) => (
<div>
<header>
<h1>{titleKey}</h1>
<Slot name="actions" />
</header>
<main>{children}</main>
</div>
),
slots: ["actions"],
};

export const MyLayout = makeLayout("MyLayout", myLayoutDef);

makeLayout(displayName, definition) returns a Layout component with a static SlotContent property for content injection.

LayoutDefinition properties​

PropertyTypeRequiredDescription
ComponentComponentType<LayoutDefinition.Properties & LayoutUtilities>Yes—
slotsstring[]No—

LayoutUtilities​

PropertyTypeRequiredDescription
Slot({ name }: { name: string }) => ReactNodeYes—

Using a layout in a screen​

Screens reference layouts via ScreenWithLayout:

const myFeature: Module<MyScreens> = {
name: "my-feature",
screens: {
myPage: {
path: "my-page",
screen: {
layout: MyLayout,
props: {
children: <MyPage />,
titleKey: "My Page",
},
},
when: "logged-in",
},
},
};

ScreenWithLayout properties​

PropertyTypeRequiredDescription
layoutunknown<Properties>Yes—
propsPropertiesYes—

Slots​

Slots let child content project into named placeholders defined by the layout, using React portals.

  1. Declare slot names in LayoutDefinition.slots
  2. Place <Slot name="..." /> in the layout component where content should appear
  3. Inject content from children using Layout.SlotContent
// Inside a page rendered within MyLayout
const MyPage = () => (
<div>
<MyLayout.SlotContent name="actions">
<Button>Create</Button>
</MyLayout.SlotContent>
<p>Page content here</p>
</div>
);

If a slot doesn't exist or SlotContent is used outside a layout context, it silently renders nothing.

Real-world example​

CustomerDashboardPageLayout (frontend/shared/global-customer-dashboard/shared-layout/CustomerDashboardPageLayout.tsx) is a production layout with actions and description slots, tabs, search, and filters.

Naming convention​

Components created with makeLayout own an entire page and are consumed via ScreenWithLayout. To distinguish them from plain React layout components (reusable sections within a page), follow this convention:

TypeSuffixCreated withExample
Page-levelPageLayoutmakeLayout()CustomerDashboardPageLayout
Section-levelLayout or descriptive namePlain React componentTwoColumnLayout

Rules:

  • The PageLayout suffix is reserved for makeLayout-based layouts consumed via ScreenWithLayout.
  • Plain React layout components (sections, wrappers, grids) must not use the PageLayout suffix.
Edit this page
Previous
Overview
  • Creating a layout
    • LayoutDefinition properties
    • LayoutUtilities
  • Using a layout in a screen
    • ScreenWithLayout properties
  • Slots
  • Real-world example
  • Naming convention