CustomerLayout
The frame around every account page, with a breadcrumb, a sidebar menu and the page title.
Framework: TanStack Start
This page is written for TanStack Start, the default and currently supported framework. See what depends on the framework.
CustomerLayout is the frame around the customer's account: profile, orders, wishlist, wallet, notifications and settings. It sits inside MasterLayout, so the header and footer stay.
What it draws
- A header band with the breadcrumb for the current page.
- A sidebar with the account menu. On the profile page it also shows the avatar with an upload button.
- The page title as an
h1, then your page. - The class
customeron<body>, for every account page. Use it to style the account area without touching other pages.
On small screens the sidebar menu is hidden and the page uses the full width.
Import
import { CustomerLayout } from '@salla.sa/twilight-theme-engine/components/layout';| Prop | Type | Description |
|---|---|---|
children | ReactNode | The account page. Required. |
page | Page | Supplies the breadcrumb and the h1 title. Optional. |
How it is used
The engine generates the /account route for you. It is a layout route: it finds the page data from whichever child route is open, then wraps that child with CustomerLayout:
function AccountLayoutComponent() {
const matches = useMatches();
const page = matches.reduceRight(
(found, m) => found ?? (m.loaderData?.page ? m.loaderData.page : null),
null,
);
return (
<CustomerLayout page={page}>
<Outlet />
</CustomerLayout>
);
}While an account page loads, the route shows CustomerLayoutSkeleton.
Replace it
CustomerLayout is not a setting. To change it, replace the /account route the same way you replace any built-in page. See Fork a built-in route.
Declare your own route for /account:
import { route } from '@tanstack/virtual-file-routes';
export const routes = [route('/account', 'account-layout.tsx')];Write the layout route. Keep <Outlet />, because that is where each account page appears:
import { createFileRoute, Outlet } from '@tanstack/react-router';
export const Route = createFileRoute('/{-$locale}/account')({
component: () => (
<div className="container">
<aside>{/* your account menu */}</aside>
<Outlet />
</div>
),
});When you replace the account layout you own the account menu, the breadcrumb and the title. Keep the customer body class if your styles use it.
See also
- Account pages
- Layouts overview
- Add content to a slot if you only need to add something