A dumb CSS Grid skeleton with sidebar, topbar, and content regions. It has no opinion on what the sidebar or topbar contain — the elements passed in are responsible for their own `grid-area: sidebar` / `grid-area: topbar` placement (e.g. via `@behivetech/atoms.sidebar`).
A dumb CSS Grid skeleton with sidebar, topbar, and content regions. It has no
opinion on what the sidebar or topbar contain — the elements passed in are
responsible for their own grid-area: sidebar / grid-area: topbar
placement (e.g. via @behivetech/atoms.sidebar).
Sidebar width, topbar height, and content max-width, padding and background are configurable via CSS custom properties, each with a sensible default:
--sidebar-layout-sidebar-width(default13.75rem)--sidebar-layout-topbar-height(default3.5rem)--sidebar-layout-content-max-width(default75rem)--sidebar-layout-content-padding(defaultvar(--spacing-8))--sidebar-layout-content-background(default the background role)
Usage
1import { SidebarLayout } from "@behivetech/templates.sidebar-layout";2import { Sidebar } from "@behivetech/atoms.sidebar";3import { NavItem } from "@behivetech/atoms.nav-item";45function Example() {6 return (7 <SidebarLayout8 sidebar={9 <Sidebar>10 <NavItem href="#" active>11 Pages12 </NavItem>13 <NavItem href="#">Media</NavItem>14 </Sidebar>15 }16 topbar={<header style={{ padding: "0.75rem 1rem" }}>Topbar</header>}17 >18 Page content19 </SidebarLayout>20 );21}
Examples
Open all 1 →1const BasicSidebarLayout = () => (2 <SidebarLayout sidebar={<nav>Sidebar</nav>} topbar={<header>Topbar</header>}>3 Page content4 </SidebarLayout>5);67render(<BasicSidebarLayout />);
Properties
SidebarLayout props
| Prop | Type | Default | Description |
|---|---|---|---|
sidebar* | ReactNode | — | Sidebar region content; the element rendered here owns its own `grid-area: sidebar` placement |
topbar* | ReactNode | — | Topbar region content; the element rendered here owns its own `grid-area: topbar` placement |
children | ReactNode | — | Main content region |
className | string | — | Additional class names to merge with the component root element |
Also accepts the native attributes of its root element (className, aria-*, event handlers, …).