@molecule/app-top-nav-layout-solid
Feature · top-nav-layout · App (browser) · v1.2.2 · Apache-2.0
Top navigation app shell: brand link + horizontal NavLinks + UserMenu slot, with a router outlet for nested routes
npm install @molecule/app-top-nav-layout-solidHow it works
@molecule/app-top-nav-layout-solid is a ready-made top-nav-layout feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { TopNavLayout, type TopNavItem } from '@molecule/app-top-nav-layout-solid'
const NAV: TopNavItem[] = [
{ key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
{ key: 'reports', to: '/reports', icon: 'bar_chart', label: 'Reports' },
]
export function Shell() {
return (
<TopNavLayout appName="Acme" navItems={NAV} userMenu={<button type="button">Account</button>}>
<main>…routed content…</main>
</TopNavLayout>
)
}Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid
Reference
Solid top navigation app shell layout for routed Solid apps.
Exports TopNavLayout — sticky header with brand link + horizontal router
links + a user-menu slot, plus the <main> holding the routed page body —
and the TopNavItem / TopNavLayoutProps types. It is the Solid
counterpart of @molecule/app-top-nav-layout-react: the same props (React
names) and the same DOM for the same input.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { TopNavLayout, type TopNavItem } from '@molecule/app-top-nav-layout-solid'
const NAV: TopNavItem[] = [
{ key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
{ key: 'reports', to: '/reports', icon: 'bar_chart', label: 'Reports' },
]
export function Shell() {
return (
<TopNavLayout appName="Acme" navItems={NAV} userMenu={<button type="button">Account</button>}>
<main>…routed content…</main>
</TopNavLayout>
)
}
Type
feature
Installation
npm install @molecule/app-top-nav-layout-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
API
Interfaces
TopNavItem
A single navigation item rendered in the top nav bar.
interface TopNavItem {
/** Route path the link goes to. */
to: string
/** Stable key — used to key the rendered link and as the i18n key suffix in apps. */
key: string
/** Material symbol icon name (or any glyph) shown next to the label. */
icon?: string
/** Visible label. Apps that route this through `t(...)` should pass the resolved string. */
label: string
}
TopNavLayoutProps
Props accepted by the TopNavLayout component.
interface TopNavLayoutProps {
/** Brand text shown in the top-left link (typically the app name). */
appName: string
/** Path the brand link navigates to. Defaults to `'/'`. */
logoTo?: string
/** Horizontal nav items rendered in the header. */
navItems: ReadonlyArray<TopNavItem>
/** Node rendered at the right of the header (typically a user menu). */
userMenu?: JSX.Element
/**
* Aria-label for the primary `<nav>`. Overrides the translated /
* `defaultValue` `'Primary navigation'` (prop > `t()` > default).
*/
navAriaLabel?: string
/** Extra classes on the outer wrapper. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
/**
* The routed page body. React renders its router's `<Outlet />` in the
* `<main>`; pass the routed view or any content here.
*/
children?: JSX.Element
}
Functions
TopNavLayout(props)
Sticky top-nav shell with brand + horizontal nav + user-menu slot.
This is the Solid counterpart of @molecule/app-top-nav-layout-react: the
same props (React names), the same ClassMap tokens, and the same DOM for the
same input. The routed page body goes in children, where React renders
React Router's <Outlet />. Nav labels are hidden below the md breakpoint
(icon-only mobile nav), so always provide icon names; they render as
Material Symbols ligatures and need the Material Symbols font loaded by the
host app. label is rendered as-is: pass an already-translated string.
function TopNavLayout(props: TopNavLayoutProps): JSX.Element
props— Component props (seeTopNavLayoutProps).
Returns: The rendered top navigation layout.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-solid^3.14.0 || ^4.0.0@molecule/app-ui^1.3.11@molecule/app-ui-solid^1.1.0solid-js^1.8.0
Runtime Dependencies
@molecule/app-solid@molecule/app-ui@molecule/app-ui-solidsolid-js
Render it as a LAYOUT ROUTE component and pass the routed view as
children: React renders React Router's <Outlet /> in the <main>, and
this package renders children there. Nav labels are hidden below the md
breakpoint (icon-only mobile nav), so always provide icon names; they
render as Material Symbols ligatures and need the Material Symbols font
loaded by the host app. Styling comes from the bonded ClassMap, so a
theme/ClassMap bond is a prerequisite. label is rendered as-is: pass an
already-translated string.
Translations
Translation strings are provided by @molecule/app-locales-top-nav-layout.