Components: Layout
The page frame: header, footer, drawers (menu, account, cart, wishlist), announcement bar, language switcher and the cookie consent banner.
Generated from apps/theme/src/components/layout/: 27 files, 29 components. Import a component through the @/components/… path shown, so a fork can override it in src/custom/.
@/components/layout/account-drawer
apps/theme/src/components/layout/account-drawer.tsx client component
<AccountDrawer>
| Prop | Type | Description |
|---|---|---|
isOpen | boolean | |
onClose | () => void | |
onCloseAutoFocus? | (event: Event) => void | Focus handling on close. Forwarded to Radix so DrawerHost can return focus to the element that opened this drawer — the trigger lives outside the Radix tree, so Radix has no triggerRef of its own to restore to. |
storeName | string |
@/components/layout/added-to-cart-drawer
apps/theme/src/components/layout/added-to-cart-drawer.tsx client component
<AddedToCartDrawer>
Post-add confirmation + upsell drawer. Opened by AddToCartButton (via the openCart header event) — NOT by the cart icon, which now links to /cart. Shows a "successfully added" header, the item just added, checkout/cart actions, and a cross-sell grid (the added product's cross-sells, falling back to best sellers when it has none). Replaces the old mini-cart drawer.
| Prop | Type | Description |
|---|---|---|
isOpen | boolean | |
onCloseAutoFocus? | (event: Event) => void | Focus handling on close. Forwarded to Radix so DrawerHost can return focus to the element that opened this drawer — the trigger lives outside the Radix tree, so Radix has no triggerRef of its own to restore to. |
detail | AddedToCartDetail | null | |
onClose | () => void |
@/components/layout/announcement-bar
apps/theme/src/components/layout/announcement-bar.tsx server component
<AnnouncementBar>
content is the announcement CMS block fetched server-side via the layout's cached getCmsBlocks, which sanitizes the HTML at the source (sanitizeBlockContent in engine catalog.ts). It renders in the initial HTML with no client round-trip. We render it directly — sanitization already happened on the server, so this component does NOT import sanitizeCmsHtml (that would pull the heavy sanitize-html/htmlparser2 parser into the client bundle). When no server content exists, the bar simply doesn't render; getCmsBlocks runs per request, so content is available whenever the block is configured.
| Prop | Type | Description |
|---|---|---|
content? | string | null |
@/components/layout/cookie-consent-banner-lazy
apps/theme/src/components/layout/cookie-consent-banner-lazy.tsx client component
<CookieConsentBannerLazy>
No props.
@/components/layout/cookie-consent-banner
apps/theme/src/components/layout/cookie-consent-banner.tsx client component
<CookieConsentBanner>
| Prop | Type | Description |
|---|---|---|
initialPreferencesOpen? | boolean | Open the preferences dialog as soon as this mounts. Set by the lazy wrapper when the shopper clicked "cookie preferences" in the footer: that click is what triggers the chunk load, so the OPEN_PREFERENCES_EVENT has already fired and been missed by the time the listener below is registered. |
@/components/layout/footer
apps/theme/src/components/layout/footer.tsx client component
@/components/layout/header/account-trigger
apps/theme/src/components/layout/header/account-trigger.tsx client component
<AccountTrigger>
Account button. Emits open-account (also dispatched from elsewhere, e.g. the guest-order page) which the DrawerHost island opens on.
| Prop | Type | Description |
|---|---|---|
ariaLabel | string |
@/components/layout/header/cart-trigger
apps/theme/src/components/layout/header/cart-trigger.tsx client component
<CartTrigger>
Cart link + live quantity badge. Navigates to the full /cart page — the drawer is now reserved for the post-add confirmation/upsell surface (AddedToCartDrawer), which AddToCartButton opens via open-cart. Still hydrates eagerly (the badge count is client-only, from CartProvider).
No props.
@/components/layout/header/desktop-search-panel
apps/theme/src/components/layout/header/desktop-search-panel.tsx client component
<DesktopSearchPanel>
Desktop (lg+) search box + autocomplete dropdown. This is the heavy interactive piece that was the bulk of the old monolithic header — the live debounced useQuickSearch query, the Radix Popover, the product suggestion grid, the promotion column and the recent/top-searches empty state.
It is NOT loaded on page load. desktop-search.tsx renders an eager placeholder input (so the box is in the SSR HTML, crawlable and shift-free) and imports this module only on hover/focus, handing over what was already typed via initialTerm + autoFocus. See that file for why the swap is a hand-rolled import rather than next/dynamic.
| Prop | Type | Description |
|---|---|---|
initialTerm? | string | What the visitor had already typed into the eager placeholder input in desktop-search.tsx before this chunk finished loading. |
autoFocus? | boolean | Set when this panel replaced a focused placeholder, so focus (and the caret position) has to be handed back to the real input. |
@/components/layout/header/desktop-search
apps/theme/src/components/layout/header/desktop-search.tsx client component
<DesktopSearch>
Desktop search slot.
The search box itself is rendered here, eagerly, as plain markup — it is above the fold on every page, so it must be in the SSR HTML (crawlable, and no skeleton-to-input swap). What is deferred is the panel: the live useLazyQuery(QUICK_SEARCH), the Radix Popover, the product suggestion grid and the recent/top-searches empty state — together the single largest interaction-only chunk in the header.
It used to be deferred with next/dynamic and rendered unconditionally, which defers nothing: rendering a dynamic component fires its import during hydration and Next emits a <script async> for it in the initial HTML (the rule is stated in full in cookie-consent-banner-lazy.tsx). So the panel shipped on every route — including CMS pages nobody searches from.
The swap is done with a hand-rolled import rather than next/dynamic deliberately: dynamic renders null (or a fallback element) while the chunk is in flight, which would rip the focused input out of the DOM mid-keystroke. Keeping the placeholder mounted until the module has actually resolved means the visitor keeps typing into a live, controlled input the whole time, and initialTerm carries what they typed across the swap.
| Prop | Type | Description |
|---|---|---|
placeholder | string | |
inputLabel | string | |
submitLabel | string |
@/components/layout/header/drawer-host
apps/theme/src/components/layout/header/drawer-host.tsx client component
<DrawerHost>
Single client island that owns ALL drawer/overlay state and the four (lazy, ssr:false) drawers. The lightweight trigger buttons in the server shell only dispatch window events; header-overlays.tsx listens for them, mounts this host on the first one, and replays it via initialIntent.
TWO separate deferrals are at work, and both are load-bearing:
- This module is itself behind an
ssr:falsedynamic import thatHeaderOverlaysonly renders after the first open intent — so none of it ships in the server HTML or the initial hydration pass. - Each drawer is mounted only once it has actually been opened (
mountedbelow), and stays mounted afterwards so close animations and internal state survive. This is the part that matters for first-load JS: rendering anext/dynamiccomponent unconditionally still fires its import, so<MenuDrawer isOpen={false}>would fetch and evaluate the whole drawer chunk anyway. See the comment incookie-consent-banner-lazy.tsxfor the same rule stated in full.
Mutual exclusion (opening one drawer closes the others) is now structural: a single openDrawer key can only name one drawer at a time.
| Prop | Type | Description |
|---|---|---|
navCategories | CategoryTree[] | |
headerLinks | NavLinkConfig[] | |
menuButtonName | string | |
storeName | string | |
initialIntent? | HeaderIntent | null | The event that caused this island to be mounted. HeaderOverlays owns the listeners before this chunk exists, so the event that triggered the load has already been dispatched and no listener here could have seen it — it is replayed through this prop instead. Same cross-mount intent hand-off as CookieConsentBannerLazy's initialPreferencesOpen. |
@/components/layout/header/header-nav-link
apps/theme/src/components/layout/header/header-nav-link.tsx client component
@/components/layout/header/header-overlays
apps/theme/src/components/layout/header/header-overlays.tsx client component
<HeaderOverlays>
Owns the listeners for the header's overlay islands so the islands themselves don't have to exist yet.
This is the load-bearing half of the deferral. Rendering a next/dynamic component unconditionally still fires its import during hydration — Next emits a <script async> for it in the initial HTML and nothing is saved (the rule is stated in full in cookie-consent-banner-lazy.tsx). Previously <DrawerHost> and <MobileSearch> were rendered unconditionally here, so every route — including a static CMS page with no cart and no search — paid for the four drawer chunks, the mobile-search overlay, next-auth/react (via the account drawer's social-login buttons) and the whole Radix Dialog/Sheet surface in its first-load JS.
Now nothing mounts until the visitor actually asks for it. The trigger buttons in the server shell dispatch window events exactly as before; the listeners live HERE (this component is tiny and always hydrated), and the event that caused the mount is replayed into the island through initialIntent / initialOpen, because the island's own listener could not have existed when it fired.
WARM_EVENTS starts the chunk fetch on first interaction intent, so the first open is not waiting on the network. Warming happens strictly after hydration, so it costs nothing on the critical path.
| Prop | Type | Description |
|---|---|---|
navCategories | CategoryTree[] | |
headerLinks | NavLinkConfig[] | |
menuButtonName | string | |
storeName | string |
@/components/layout/header/header-scroll
apps/theme/src/components/layout/header/header-scroll.tsx client component
<HeaderScroll>
Thin client wrapper around the (server-rendered) header content. Owns ONLY the hide-on-scroll-down behavior: it toggles -translate-y-full on the sticky <header> and nothing else, so the logo / nav / info-bar children pass through as untouched server HTML. One effect + one boolean = a tiny hydration island.
It also publishes --header-offset on <html>: the measured height of this whole sticky block (info bar + header row + border), which is NOT the same as --header-height (the header row alone). Anything that has to clear the header — top on a nested sticky bar, scroll-margin-top on a hash anchor — must use --header-offset; --header-height only sizes the row itself. The info bar is CMS-driven (absent on some stores, wraps to two lines on narrow viewports), so the offset is measured rather than hardcoded.
| Prop | Type | Description |
|---|---|---|
children | React.ReactNode |
@/components/layout/header/header-shell
apps/theme/src/components/layout/header/header-shell.tsx server component
<Header>
Server-component header shell. Emits the static structure (info bar, logo, flex layout) as plain server HTML and delegates only the genuinely-interactive pieces to small client islands: HeaderScroll (hide-on-scroll), DesktopSearch (deferred), the five trigger buttons, HeaderNavLink (marks the current page's nav link) and HeaderOverlays (drawers + mobile search). This replaces the old 754-line monolithic "use client" Header that hydrated eagerly on every page.
The nav/store-config data is fetched + passed by SiteHeader (see layout.tsx) and is always present, so the old client GET_NAVIGATION_CATEGORIES / GET_STORE_CONFIG fallback queries (and the header-level progress bar they drove) are gone — keeping Apollo useQuery off the header entirely; the live search islands still use useLazyQuery.
| Prop | Type | Description |
|---|---|---|
infoBarContent? | string | null | |
navigationCategories? | CategoryTree[] | |
storeName? | string | null | Magento storeConfig.store_name of the active store view. |
@/components/layout/header/menu-trigger
apps/theme/src/components/layout/header/menu-trigger.tsx client component
@/components/layout/header/mobile-search-trigger
apps/theme/src/components/layout/header/mobile-search-trigger.tsx client component
<MobileSearchTrigger>
Mobile (lg:hidden) search button. Emits open-mobile-search, which mounts/ opens the full-screen MobileSearch island.
| Prop | Type | Description |
|---|---|---|
ariaLabel | string |
@/components/layout/header/mobile-search
apps/theme/src/components/layout/header/mobile-search.tsx client component
<MobileSearch>
Full-screen mobile (lg:hidden) search overlay. Loaded via next/dynamic ssr:false (see header-overlays.tsx) since it's a portal that only ever appears on interaction — same rationale as the drawers. Opens when the MobileSearchTrigger button dispatches open-mobile-search.
HeaderOverlays does not render this island until that event first fires, so the listener below cannot have seen the event that caused the mount — it is replayed as initialOpen. Every LATER open goes through the listener as before, because the island stays mounted once loaded.
| Prop | Type | Description |
|---|---|---|
initialOpen? | boolean |
@/components/layout/header/quick-search-grid
apps/theme/src/components/layout/header/quick-search-grid.tsx client component
<QuickSearchGrid>
Product results grid for the header quick-search dropdown (desktop panel and mobile overlay). className sets the column count per surface.
| Prop | Type | Description |
|---|---|---|
products | QuickSearchProduct[] | |
ariaLabel | string | |
onNavigate | () => void | |
className? | string |
<QuickSearchPromotionGroups>
The promotion rows from groupPromotions — categories, products, brands — stacked, each under its own heading. className sets the tile columns.
| Prop | Type | Description |
|---|---|---|
groups | PromotionGroup[] | |
onNavigate | () => void | |
className? | string |
@/components/layout/header/search-empty-panel
apps/theme/src/components/layout/header/search-empty-panel.tsx client component
<SearchEmptyPanel>
The quick-search panels' empty-focus content: "Recent searches" (with a clear button) and "Top searches". Purely presentational — feed it from useEmptySearchSuggestions so the desktop dropdown can gate its container on hasContent. Each term is a button; onPick navigates to /search.
| Prop | Type | Description |
|---|---|---|
recent | string[] | |
topTerms | string[] | |
onPick | (term: string) => void | |
onClearRecent | () => void |
@/components/layout/header/wishlist-trigger
apps/theme/src/components/layout/header/wishlist-trigger.tsx client component
<WishlistTrigger>
Wishlist button + live count badge. Hydrates eagerly (the count is client-only, from WishlistProvider). Emits open-wishlist.
No props.
@/components/layout/language-switcher-flag
apps/theme/src/components/layout/language-switcher-flag.tsx client component
<FlagImage>
Shared by the eager header trigger (language-switcher.tsx) and the lazy drawer (language-switcher-panel.tsx), so the country map is defined once.
| Prop | Type | Description |
|---|---|---|
locale | string | |
className? | string | |
eager? | boolean |
<FlagPlaceholder>
| Prop | Type | Description |
|---|---|---|
className? | string |
@/components/layout/language-switcher-panel
apps/theme/src/components/layout/language-switcher-panel.tsx client component
<LanguageSwitcherPanel>
The store-switcher drawer. Split out of language-switcher.tsx and loaded on first open, because everything in here is every-page dead weight otherwise: the Radix Sheet (Dialog → portal, focus-scope, dismissable-layer, presence, react-remove-scroll, aria-hidden).
Store names come from the engine config's stores (Magento's store_name, snapshotted at build time) — no GraphQL here at all.
The trigger button stays eager (it renders the current flag above the fold); only this body is deferred.
| Prop | Type | Description |
|---|---|---|
isOpen | boolean | |
onOpenChange | (open: boolean) => void | |
currentLocale | string |
@/components/layout/language-switcher
apps/theme/src/components/layout/language-switcher.tsx client component
<LanguageSwitcher>
Header store/locale switcher: an eager trigger button and a lazy drawer.
The trigger is above the fold on every page, so it renders eagerly. The drawer is not: it used to be a static Sheet import in this file, which put @radix-ui/react-dialog (portal, focus-scope, dismissable-layer, presence, react-remove-scroll, aria-hidden) into the MAIN header chunk on every route — defeating, from one line, the whole ssr:false deferral drawer-host.tsx was built for.
{opened && …} is what makes the split real: rendering the dynamic component unconditionally would fire its import during hydration and save nothing (see cookie-consent-banner-lazy.tsx). warm() on hover/focus of this button starts the fetch before the click, so the drawer still opens instantly.
No props.
@/components/layout/menu-drawer
apps/theme/src/components/layout/menu-drawer.tsx client component
@/components/layout/wishlist-drawer-recommendations
apps/theme/src/components/layout/wishlist-drawer-recommendations.tsx client component
<WishlistDrawerRecommendations>
Merchandising for the EMPTY wishlist drawer: shows the shopper's recently viewed products (localStorage, same source as the PDP "Recently Viewed" section) as miniature rows matching the wishlist item style. When there are no recently viewed products yet (fresh visitor), it falls back to a few current deals and best sellers instead. Those lists are only requested when the drawer is open AND there's nothing recently viewed, so a returning shopper never triggers them — and they come from the cached /api/deals and /api/best-sellers routes, not a live Magento query per visitor.
| Prop | Type | Description |
|---|---|---|
isOpen | boolean | |
onClose | () => void |
@/components/layout/wishlist-drawer
apps/theme/src/components/layout/wishlist-drawer.tsx client component
<WishlistDrawer>
| Prop | Type | Description |
|---|---|---|
isOpen | boolean | |
onClose | () => void | |
onCloseAutoFocus? | (event: Event) => void | Focus handling on close. Forwarded to Radix so DrawerHost can return focus to the element that opened this drawer — the trigger lives outside the Radix tree, so Radix has no triggerRef of its own to restore to. |